tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r801705 - in /tomcat/trunk/java/org/apache: catalina/connector/AsyncContextImpl.java coyote/http11/Http11NioProcessor.java
Date Thu, 06 Aug 2009 16:25:04 GMT
Author: fhanik
Date: Thu Aug  6 16:25:04 2009
New Revision: 801705

URL: http://svn.apache.org/viewvc?rev=801705&view=rev
Log:
If dispatch is called on a worker thread, simply execute it, instead of throwing exception.
No need to hand off to container


Modified:
    tomcat/trunk/java/org/apache/catalina/connector/AsyncContextImpl.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java

Modified: tomcat/trunk/java/org/apache/catalina/connector/AsyncContextImpl.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/AsyncContextImpl.java?rev=801705&r1=801704&r2=801705&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/AsyncContextImpl.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/AsyncContextImpl.java Thu Aug  6 16:25:04
2009
@@ -122,7 +122,17 @@
                 }
             };
             this.dispatch = run;
-            request.coyoteRequest.action(ActionCode.ACTION_ASYNC_DISPATCH, null );
+            AtomicBoolean dispatched = new AtomicBoolean(false);
+            request.coyoteRequest.action(ActionCode.ACTION_ASYNC_DISPATCH, dispatched );
+            if (!dispatched.get()) {
+                try {
+                    doInternalDispatch();
+                }catch (ServletException sx) {
+                    throw new RuntimeException(sx);
+                }catch (IOException ix) {
+                    throw new RuntimeException(ix);
+                }
+            }
 
         } else {
             throw new IllegalStateException("Dispatch not allowed. Invalid state:"+state.get());
@@ -154,7 +164,17 @@
                 }
             };
             this.dispatch = r;
-            request.coyoteRequest.action(ActionCode.ACTION_ASYNC_DISPATCH, null );
+            AtomicBoolean dispatched = new AtomicBoolean(false);
+            request.coyoteRequest.action(ActionCode.ACTION_ASYNC_DISPATCH, dispatched );
+            if (!dispatched.get()) {
+                try {
+                    doInternalDispatch();
+                }catch (ServletException sx) {
+                    throw new RuntimeException(sx);
+                }catch (IOException ix) {
+                    throw new RuntimeException(ix);
+                }
+            }
         } else {
             throw new IllegalStateException("Dispatch not allowed. Invalid state:"+state.get());
         }

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=801705&r1=801704&r2=801705&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java Thu Aug  6 16:25:04
2009
@@ -1323,10 +1323,11 @@
             attach.setTimeout(timeout);
         } 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.processSocket(this.socket, SocketStatus.OPEN, true);
             } else { 
-                throw new UnsupportedOperationException("Can't call dispatch on the worker
thread.");
+                dispatch.set(true);
             }
         }
     }



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


Mime
View raw message