Fix crash observed during pausing the connector when using APR.
authorrjung <rjung@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 13 Jun 2011 18:14:46 +0000 (18:14 +0000)
committerrjung <rjung@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 13 Jun 2011 18:14:46 +0000 (18:14 +0000)
Only add socket to poller if we are sure we don't close it later.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1135208 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/ajp/AjpAprProcessor.java
java/org/apache/coyote/http11/Http11AprProcessor.java
webapps/docs/changelog.xml

index 783d54a..32270e8 100644 (file)
@@ -319,13 +319,6 @@ public class AjpAprProcessor extends AbstractAjpProcessor {
             recycle();
         }
 
-        // Add the socket to the poller
-        if (!error && !endpoint.isPaused()) {
-            if (!isAsync()) {
-                ((AprEndpoint)endpoint).getPoller().add(socketRef);
-            }
-        }
-
         rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);
         
         if (error || endpoint.isPaused()) {
@@ -333,6 +326,8 @@ public class AjpAprProcessor extends AbstractAjpProcessor {
         } else if (isAsync()) {
             return SocketState.LONG;
         } else {
+            // Add the socket to the poller
+            ((AprEndpoint)endpoint).getPoller().add(socketRef);
             return SocketState.OPEN;
         }
     }
index 37fa1b2..2f16597 100644 (file)
@@ -212,6 +212,7 @@ public class Http11AprProcessor extends AbstractHttp11Processor {
         
         boolean keptAlive = false;
         boolean openSocket = false;
+        boolean addToPoller = false;
 
         while (!error && keepAlive && !comet && !isAsync() && !endpoint.isPaused()) {
 
@@ -225,14 +226,13 @@ public class Http11AprProcessor extends AbstractHttp11Processor {
                     // (long keepalive), so that the processor should be recycled
                     // and the method should return true
                     openSocket = true;
-                    // Add the socket to the poller
-                    ((AprEndpoint)endpoint).getPoller().add(socketRef);
                     if (endpoint.isPaused()) {
                         // 503 - Service unavailable
                         response.setStatus(503);
                         adapter.log(request, response, 0);
                         error = true;
                     } else {
+                        addToPoller = true;
                         break;
                     }
                 }
@@ -350,6 +350,10 @@ public class Http11AprProcessor extends AbstractHttp11Processor {
         } else if (comet  || isAsync()) {
             return SocketState.LONG;
         } else {
+            // Add the socket to the poller
+            if (addToPoller) {
+                ((AprEndpoint)endpoint).getPoller().add(socketRef);
+            }
             return (openSocket) ? SocketState.OPEN : SocketState.CLOSED;
         }
         
index d598de5..0d61feb 100644 (file)
         Remove superfluous quotes from thread names for connection pools.
         (rjung)
       </fix>
+      <fix>
+        Fix crash observed during pausing the connector when using APR.
+        Only add socket to poller if we are sure we don't close it later.
+        (rjung)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Cluster">