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 2011/07/28 20:16:41 UTC

svn commit: r1151953 - in /tomcat/trunk: java/org/apache/coyote/AbstractProtocol.java java/org/apache/coyote/http11/Http11AprProcessor.java java/org/apache/tomcat/util/net/AbstractEndpoint.java webapps/docs/changelog.xml

Author: markt
Date: Thu Jul 28 18:16:39 2011
New Revision: 1151953

URL: http://svn.apache.org/viewvc?rev=1151953&view=rev
Log:
Ensure APR socket is not added to multiple pollers.

Modified:
    tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
    tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java?rev=1151953&r1=1151952&r2=1151953&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java Thu Jul 28 18:16:39 2011
@@ -525,10 +525,15 @@ public abstract class AbstractProtocol i
                     // socket associated with the processor. Exact requirements
                     // depend on type of long poll
                     longPoll(socket, processor);
-                } else if (state == SocketState.OPEN){
+                } else if (state == SocketState.OPEN) {
                     // In keep-alive but between requests. OK to recycle
                     // processor. Continue to poll for the next request.
                     release(socket, processor, false, true);
+                } else if (state == SocketState.SENDFILE) {
+                    // Sendfile in progress. If it fails, the socket will be
+                    // closed. If it works, the socket will be re-added to the
+                    // poller
+                    release(socket, processor, false, false);
                 } else {
                     // Connection closed. OK to recycle the processor.
                     release(socket, processor, true, false);

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java?rev=1151953&r1=1151952&r2=1151953&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java Thu Jul 28 18:16:39 2011
@@ -185,6 +185,7 @@ public class Http11AprProcessor extends 
         
         boolean keptAlive = false;
         boolean openSocket = false;
+        boolean sendfileInProgress = false;
 
         while (!error && keepAlive && !comet && !isAsync() && !endpoint.isPaused()) {
 
@@ -305,17 +306,19 @@ public class Http11AprProcessor extends 
                 sendfileData.socket = socketRef;
                 sendfileData.keepAlive = keepAlive;
                 if (!((AprEndpoint)endpoint).getSendfile().add(sendfileData)) {
+                    // Didn't send all of the data to sendfile.
                     if (sendfileData.socket == 0) {
-                        // Didn't send all the data but the socket is no longer
-                        // set. Something went wrong. Close the connection.
-                        // Too late to set status code.
+                        // The socket is no longer set. Something went wrong.
+                        // Close the connection. Too late to set status code.
                         if (log.isDebugEnabled()) {
                             log.debug(sm.getString(
                                     "http11processor.sendfile.error"));
                         }
                         error = true;
                     } else {
-                        openSocket = true;
+                        // The sendfile Poller will add the socket to the main
+                        // Poller once sendfile processing is complete
+                        sendfileInProgress = true;
                     }
                     break;
                 }
@@ -332,7 +335,11 @@ public class Http11AprProcessor extends 
         } else if (comet  || isAsync()) {
             return SocketState.LONG;
         } else {
-            return (openSocket) ? SocketState.OPEN : SocketState.CLOSED;
+            if (sendfileInProgress) {
+                return SocketState.SENDFILE;
+            } else {
+                return (openSocket) ? SocketState.OPEN : SocketState.CLOSED;
+            }
         }
         
     }

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java?rev=1151953&r1=1151952&r2=1151953&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/AbstractEndpoint.java Thu Jul 28 18:16:39 2011
@@ -54,7 +54,7 @@ public abstract class AbstractEndpoint {
         public enum SocketState {
             // TODO Add a new state to the AsyncStateMachine and remove
             //      ASYNC_END (if possible)
-            OPEN, CLOSED, LONG, ASYNC_END
+            OPEN, CLOSED, LONG, ASYNC_END, SENDFILE
         }
         
 

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1151953&r1=1151952&r2=1151953&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Thu Jul 28 18:16:39 2011
@@ -124,6 +124,10 @@
         Improve error handling for HTTP APR if an error occurs while using
         sendfile. (markt) 
       </add>
+      <fix>
+        Ensure that when using sendfile, HTTP APR sockets are not added to
+        multiple pollers. This may cause errors during shutdown. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">



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