tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1478714 - in /tomcat/trunk/java/org/apache/coyote/http11: AbstractHttp11Processor.java Http11NioProcessor.java
Date Fri, 03 May 2013 10:18:21 GMT
Author: markt
Date: Fri May  3 10:18:20 2013
New Revision: 1478714

URL: http://svn.apache.org/r1478714
Log:
Pull-up non-blocking code for asyncDispatch from NioHttp11Processor to AbstractHttp11Processor

Modified:
    tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java

Modified: tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java?rev=1478714&r1=1478713&r2=1478714&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java Fri May  3 10:18:20
2013
@@ -23,6 +23,7 @@ import java.util.StringTokenizer;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.regex.Pattern;
 
+import javax.servlet.RequestDispatcher;
 import javax.servlet.http.HttpUpgradeHandler;
 
 import org.apache.coyote.AbstractProcessor;
@@ -1540,6 +1541,46 @@ public abstract class AbstractHttp11Proc
     @Override
     public SocketState asyncDispatch(SocketStatus status) {
 
+        if (status == SocketStatus.OPEN_WRITE) {
+            try {
+                asyncStateMachine.asyncOperation();
+                try {
+                    if (outputBuffer.hasDataToWrite()) {
+                        //System.out.println("Attempting data flush!!");
+                        outputBuffer.flushBuffer(false);
+                    }
+                    //return if we have more data to write
+                    if (registerForWrite()) {
+                        return SocketState.LONG;
+                    }
+                } catch (IOException x) {
+                    if (getLog().isDebugEnabled()) {
+                        getLog().debug("Unable to write async data.",x);
+                    }
+                    status = SocketStatus.ASYNC_WRITE_ERROR;
+                    request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, x);
+                }
+            } catch (IllegalStateException x) {
+                registerForEvent(false, true);
+            }
+        } else if (status == SocketStatus.OPEN_READ) {
+            try {
+                try {
+                    if (inputBuffer.nbRead()>0) {
+                        asyncStateMachine.asyncOperation();
+                    }
+                } catch (IOException x) {
+                    if (getLog().isDebugEnabled()) {
+                        getLog().debug("Unable to read async data.",x);
+                    }
+                    status = SocketStatus.ASYNC_READ_ERROR;
+                    request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, x);
+                }
+            } catch (IllegalStateException x) {
+                registerForEvent(false, true);
+            }
+        }
+
         RequestInfo rp = request.getRequestProcessor();
         try {
             rp.setStage(org.apache.coyote.Constants.STAGE_SERVICE);
@@ -1564,6 +1605,7 @@ public abstract class AbstractHttp11Proc
         if (error) {
             return SocketState.CLOSED;
         } else if (isAsync()) {
+            registerForWrite();
             return SocketState.LONG;
         } else {
             if (!keepAlive) {

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java?rev=1478714&r1=1478713&r2=1478714&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java Fri May  3 10:18:20
2013
@@ -22,7 +22,6 @@ import java.net.InetAddress;
 import java.nio.channels.SelectionKey;
 
 import javax.net.ssl.SSLEngine;
-import javax.servlet.RequestDispatcher;
 
 import org.apache.coyote.ActionCode;
 import org.apache.coyote.RequestInfo;
@@ -160,57 +159,6 @@ public class Http11NioProcessor extends 
     }
 
 
-
-
-    @Override
-    public SocketState asyncDispatch(SocketStatus status) {
-
-
-        if (status == SocketStatus.OPEN_WRITE) {
-            try {
-                asyncStateMachine.asyncOperation();
-                try {
-                    if (outputBuffer.hasDataToWrite()) {
-                        //System.out.println("Attempting data flush!!");
-                        outputBuffer.flushBuffer(false);
-                    }
-                    //return if we have more data to write
-                    if (registerForWrite()) {
-                        return SocketState.LONG;
-                    }
-                } catch (IOException x) {
-                    if (log.isDebugEnabled()) log.debug("Unable to write async data.",x);
-                    status = SocketStatus.ASYNC_WRITE_ERROR;
-                    request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, x);
-                }
-            } catch (IllegalStateException x) {
-                registerForEvent(false, true);
-            }
-        } else if (status == SocketStatus.OPEN_READ) {
-            try {
-                try {
-                    if (inputBuffer.nbRead()>0) {
-                        asyncStateMachine.asyncOperation();
-                    }
-                } catch (IOException x) {
-                    if (log.isDebugEnabled()) log.debug("Unable to read async data.",x);
-                    status = SocketStatus.ASYNC_READ_ERROR;
-                    request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, x);
-                }
-            } catch (IllegalStateException x) {
-                registerForEvent(false, true);
-            }
-        }
-
-        SocketState state = super.asyncDispatch(status);
-        if (state == SocketState.LONG) {
-            registerForWrite();
-        }
-
-        return state;
-    }
-
-
     @Override
     protected void registerForEvent(boolean read, boolean write) {
         final NioEndpoint.KeyAttachment attach =



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


Mime
View raw message