Start to align the request finish code
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 5 Sep 2011 12:09:28 +0000 (12:09 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 5 Sep 2011 12:09:28 +0000 (12:09 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1165253 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/http11/Http11AprProcessor.java
java/org/apache/coyote/http11/Http11NioProcessor.java
java/org/apache/coyote/http11/Http11Processor.java

index 3b19181..fa6a1f1 100644 (file)
@@ -290,15 +290,20 @@ public class Http11AprProcessor extends AbstractHttp11Processor<Long> {
             }
 
             // Finish the handling of the request
-            if (!comet && !isAsync()) {
-                // If we know we are closing the connection, don't drain input.
-                // This way uploading a 100GB file doesn't tie up the thread 
-                // if the servlet has rejected it.
-                if(error)
+            rp.setStage(org.apache.coyote.Constants.STAGE_ENDINPUT);
+
+            if (!isAsync() && !comet) {
+                if (error) {
+                    // If we know we are closing the connection, don't drain
+                    // input. This way uploading a 100GB file doesn't tie up the
+                    // thread if the servlet has rejected it.
                     inputBuffer.setSwallowInput(false);
+                }
                 endRequest();
             }
 
+            rp.setStage(org.apache.coyote.Constants.STAGE_ENDOUTPUT);
+
             // If there was an error, make sure the request is counted as
             // and error, and update the statistics counter
             if (error) {
@@ -336,7 +341,6 @@ public class Http11AprProcessor extends AbstractHttp11Processor<Long> {
             }
             
             rp.setStage(org.apache.coyote.Constants.STAGE_KEEPALIVE);
-
         }
 
         rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);
index afdddfb..6d68bdd 100644 (file)
@@ -351,15 +351,20 @@ public class Http11NioProcessor extends AbstractHttp11Processor<NioChannel> {
             }
 
             // Finish the handling of the request
-            if (!comet && !isAsync()) {
-                // If we know we are closing the connection, don't drain input.
-                // This way uploading a 100GB file doesn't tie up the thread 
-                // if the servlet has rejected it.
-                if(error)
+            rp.setStage(org.apache.coyote.Constants.STAGE_ENDINPUT);
+
+            if (!isAsync() && !comet) {
+                if(error) {
+                    // If we know we are closing the connection, don't drain
+                    // input. This way uploading a 100GB file doesn't tie up the
+                    // thread if the servlet has rejected it.
                     inputBuffer.setSwallowInput(false);
+                }
                 endRequest();
             }
 
+            rp.setStage(org.apache.coyote.Constants.STAGE_ENDOUTPUT);
+
             // If there was an error, make sure the request is counted as
             // and error, and update the statistics counter
             if (error) {
@@ -385,10 +390,8 @@ public class Http11NioProcessor extends AbstractHttp11Processor<NioChannel> {
                 break;
             }
 
-
             rp.setStage(org.apache.coyote.Constants.STAGE_KEEPALIVE);
-
-        }//while
+        }
 
         rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);
         if (error || endpoint.isPaused()) {
index 1cb445c..0f006ba 100644 (file)
@@ -284,16 +284,16 @@ public class Http11Processor extends AbstractHttp11Processor<Socket> {
 
             // Finish the handling of the request
             rp.setStage(org.apache.coyote.Constants.STAGE_ENDINPUT);
-            
-            if(error && !isAsync()) {
-                // If we know we are closing the connection, don't drain
-                // input. This way uploading a 100GB file doesn't tie up the
-                // thread if the servlet has rejected it.
-                inputBuffer.setSwallowInput(false);
-            }
 
-            if (!isAsync())
+            if(!isAsync() && !comet) {
+                if (error) {
+                    // If we know we are closing the connection, don't drain
+                    // input. This way uploading a 100GB file doesn't tie up the
+                    // thread if the servlet has rejected it.
+                    inputBuffer.setSwallowInput(false);
+                }
                 endRequest();
+            }
 
             rp.setStage(org.apache.coyote.Constants.STAGE_ENDOUTPUT);
 
@@ -304,11 +304,6 @@ public class Http11Processor extends AbstractHttp11Processor<Socket> {
             }
             request.updateCounters();
 
-            rp.setStage(org.apache.coyote.Constants.STAGE_KEEPALIVE);
-
-            // Don't reset the param - we'll see it as ended. Next request
-            // will reset it
-            // thrA.setParam(null);
             // Next request
             if (!isAsync() || error) {
                 inputBuffer.nextRequest();
@@ -320,6 +315,8 @@ public class Http11Processor extends AbstractHttp11Processor<Socket> {
             if (isAsync() || error || inputBuffer.lastValid == 0) {
                 break;
             }
+
+            rp.setStage(org.apache.coyote.Constants.STAGE_KEEPALIVE);
         }
 
         rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);