tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1498377 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/catalina/tribes/transport/LocalStrings.properties java/org/apache/catalina/tribes/transport/nio/NioReceiver.java webapps/docs/changelog.xml
Date Mon, 01 Jul 2013 11:09:52 GMT
Author: markt
Date: Mon Jul  1 11:09:51 2013
New Revision: 1498377

URL: http://svn.apache.org/r1498377
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=54086
If stopListening is called while the thread is processing selector events it is possible for
two threads to try to use the keys collection at the same time. Prevent the ConcurrentModificationException
that can occur.

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/transport/LocalStrings.properties
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1498363

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/transport/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/transport/LocalStrings.properties?rev=1498377&r1=1498376&r2=1498377&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/transport/LocalStrings.properties
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/transport/LocalStrings.properties
Mon Jul  1 11:09:51 2013
@@ -36,4 +36,7 @@ IDataSender.senderModes.Instantiate=Can'
 IDataSender.senderModes.Missing=Can't configure a data replication sender for mode {0}
 IDataSender.senderModes.Resources=Can't load data replication sender mapping list
 IDataSender.stats=Send stats from [{0}:{1,number,integer}], Nr of bytes sent={2,number,integer}
over {3} = {4,number,integer} bytes/request, processing time {5,number,integer} msec, avg
processing time {6,number,integer} msec
+
+NioReceiver.stop.threadRunning=The NioReceiver thread did not stop in a timely manner. Errors
may be observed when the selector is closed.
+
 PooledSender.senderDisconnectFail=Failed to disconnect sender

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java?rev=1498377&r1=1498376&r2=1498377&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java Mon
Jul  1 11:09:51 2013
@@ -59,7 +59,10 @@ public class NioReceiver extends Receive
      */
     private static final String info = "NioReceiver/1.0";
 
+    private volatile boolean running = false;
+
     private AtomicReference<Selector> selector = new AtomicReference<Selector>();
+
     private ServerSocketChannel serverChannel = null;
     private DatagramChannel datagramChannel = null;
 
@@ -364,7 +367,17 @@ public class NioReceiver extends Receive
         Selector selector = this.selector.get();
         if (selector != null) {
             try {
+                // Unlock the thread if is is blocked waiting for input
                 selector.wakeup();
+                // Wait for the receiver thread to finish
+                int count = 0;
+                while (running && count < 50) {
+                    Thread.sleep(100);
+                    count ++;
+                }
+                if (running) {
+                    log.warn(sm.getString("NioReceiver.stop.threadRunning"));
+                }
                 closeSelector();
             } catch (Exception x) {
                 log.error("Unable to close cluster receiver selector.", x);
@@ -416,10 +429,13 @@ public class NioReceiver extends Receive
      */
     @Override
     public void run() {
+        running = true;
         try {
             listen();
         } catch (Exception x) {
             log.error("Unable to run replication listener.", x);
+        } finally {
+            running = false;
         }
     }
 

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1498377&r1=1498376&r2=1498377&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Mon Jul  1 11:09:51 2013
@@ -146,6 +146,10 @@
         workQueue in order to ensure that executor&apos;s <code>maxThread</code>
         works correctly. (kfujino)
       </fix>
+      <fix>
+        <bug>54086</bug>: Fix an additional code path that could lead to
+        multiple threads attempting to modify the same selector key set. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Web applications">



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message