Author: jfclere
Date: Fri Apr 16 14:44:50 2010
New Revision: 934936

URL: http://svn.apache.org/viewvc?rev=934936&view=rev
Log:
Fix asyn with APR.

Modified:
    tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java

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=934936&r1=934935&r2=934936&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java 
(original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java Fri Apr 
16 14:44:50 2010
@@ -21,6 +21,7 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InterruptedIOException;
 import java.util.StringTokenizer;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 import java.security.cert.CertificateFactory;
@@ -181,6 +182,12 @@ public class Http11AprProcessor implemen
 
 
     /**
+     * Async used
+     */
+    protected boolean async = false;
+
+
+    /**
      * Content delimiter for the request (if false, the connection will
      * be closed at the end of the request).
      */
@@ -777,6 +784,7 @@ public class Http11AprProcessor implemen
         // Error flag
         error = false;
         comet = false;
+        async = false;
         keepAlive = true;
 
         int keepAliveLeft = maxKeepAliveRequests;
@@ -785,7 +793,7 @@ public class Http11AprProcessor implemen
         boolean keptAlive = false;
         boolean openSocket = false;
 
-        while (!error && keepAlive && !comet) {
+        while (!error && keepAlive && !comet && !async) {
 
             // Parsing the request header
             try {
@@ -862,7 +870,7 @@ public class Http11AprProcessor implemen
             }
 
             // Finish the handling of the request
-            if (!comet) {
+            if (!comet && !async) {
                 // 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.
@@ -878,7 +886,7 @@ public class Http11AprProcessor implemen
             }
             request.updateCounters();
 
-            if (!comet) {
+            if (!comet && !async) {
                 // Next request
                 inputBuffer.nextRequest();
                 outputBuffer.nextRequest();
@@ -900,7 +908,7 @@ public class Http11AprProcessor implemen
 
         rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);
 
-        if (comet) {
+        if (comet  || async) {
             if (error) {
                 inputBuffer.nextRequest();
                 outputBuffer.nextRequest();
@@ -1010,6 +1018,7 @@ public class Http11AprProcessor implemen
             // transactions with the client
 
             comet = false;
+            async = false;
             try {
                 outputBuffer.endRequest();
             } catch (IOException e) {
@@ -1212,10 +1221,32 @@ public class Http11AprProcessor implemen
             //no op
         } else if (actionCode == ActionCode.ACTION_ASYNC_START) {
             //TODO SERVLET3 - async
+            async = true;
         } else if (actionCode == ActionCode.ACTION_ASYNC_COMPLETE) {
           //TODO SERVLET3 - async
+            AtomicBoolean dispatch = (AtomicBoolean)param;
+            RequestInfo rp = request.getRequestProcessor();
+            if ( rp.getStage() != org.apache.coyote.Constants.STAGE_SERVICE ) 
{ //async handling
+                dispatch.set(true);
+                // endpoint.processSocket(this.socket, SocketStatus.STOP);
+            } else {
+                dispatch.set(false);
+            }
         } else if (actionCode == ActionCode.ACTION_ASYNC_SETTIMEOUT) {
           //TODO SERVLET3 - async
+            if (param==null) return;
+            if (socket==0) return;
+            long timeout = ((Long)param).longValue();
+            Socket.timeoutSet(socket, timeout * 1000);
+        } else if (actionCode == ActionCode.ACTION_ASYNC_DISPATCH) {
+            RequestInfo rp = request.getRequestProcessor();
+            AtomicBoolean dispatch = (AtomicBoolean)param;
+            if ( rp.getStage() != org.apache.coyote.Constants.STAGE_SERVICE ) 
{//async handling
+                endpoint.getPoller().add(this.socket);
+                dispatch.set(true);
+            } else {
+                dispatch.set(true);
+            }
         }
         
 



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

Reply via email to