You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/02/03 15:47:16 UTC

svn commit: r1441920 - /tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java

Author: markt
Date: Sun Feb  3 14:47:15 2013
New Revision: 1441920

URL: http://svn.apache.org/viewvc?rev=1441920&view=rev
Log:
Make sure a socket doesn't get left in limbo if it is passed to Poller.add() after the Poller has stopped (which may happen with a long running request thread).

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?rev=1441920&r1=1441919&r2=1441920&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Sun Feb  3 14:47:15 2013
@@ -1339,7 +1339,11 @@ public class AprEndpoint extends Abstrac
         }
 
 
-        protected void stop() {
+        /*
+         * This method is synchronized so that it is not possible for a socket
+         * to be added to the Poller's addList once this method has completed.
+         */
+        protected synchronized void stop() {
             pollerRunning = false;
         }
 
@@ -1421,8 +1425,10 @@ public class AprEndpoint extends Abstrac
             boolean ok = false;
             synchronized (this) {
                 // Add socket to the list. Newly added sockets will wait
-                // at most for pollTime before being polled
-                if (addList.add(socket, timeout, flags)) {
+                // at most for pollTime before being polled. Don't add the
+                // socket once the poller has stopped but destroy it straight
+                // away
+                if (pollerRunning && addList.add(socket, timeout, flags)) {
                     ok = true;
                     this.notify();
                 }



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