tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r801414 - in /tomcat/trunk/java/org/apache: catalina/connector/AsyncContextImpl.java coyote/http11/Http11NioProcessor.java
Date Wed, 05 Aug 2009 21:16:47 GMT
Author: fhanik
Date: Wed Aug  5 21:16:47 2009
New Revision: 801414

URL: http://svn.apache.org/viewvc?rev=801414&view=rev
Log:
more work on the complete

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=801414&r1=801413&r2=801414&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/AsyncContextImpl.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/AsyncContextImpl.java Wed Aug  5 21:16:47
2009
@@ -19,6 +19,7 @@
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
 
 import javax.servlet.AsyncContext;
@@ -35,6 +36,7 @@
 import org.apache.coyote.ActionCode;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.MutableInteger;
 /**
  * 
  * @author fhanik
@@ -65,8 +67,12 @@
 
     @Override
     public void complete() {
-        // TODO SERVLET3 - async
-        doInternalComplete(false);
+        if (state.compareAndSet(AsyncState.STARTED, AsyncState.COMPLETING)) {
+            // TODO SERVLET3 - async
+            AtomicBoolean dispatched = new AtomicBoolean(false);
+            request.coyoteRequest.action(ActionCode.ACTION_ASYNC_COMPLETE,dispatched);
+            if (!dispatched.get()) doInternalComplete(false);
+        }
     }
 
     @Override
@@ -221,9 +227,15 @@
     
     public void doInternalDispatch() throws ServletException, IOException {
         if (this.state.compareAndSet(AsyncState.TIMING_OUT, AsyncState.DISPATCHED)) {
+            boolean listenerInvoked = false;
             for (AsyncListenerWrapper listener : listeners) {
                 listener.fireOnTimeout();
+                listenerInvoked = true;
+            }
+            if (!listenerInvoked) {
+                ((HttpServletResponse)servletResponse).setStatus(500);
             }
+            doInternalComplete(true);
         } else if (this.state.compareAndSet(AsyncState.DISPATCHING, AsyncState.DISPATCHED))
{
             if (this.dispatch!=null) {
                 try {
@@ -264,8 +276,8 @@
             }catch (Exception x) {
                 log.error("",x);
             }
-            request.coyoteRequest.action(ActionCode.ACTION_ASYNC_COMPLETE,null);
             recycle();
+            
         } else { 
             throw new IllegalStateException("Complete illegal. 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=801414&r1=801413&r2=801414&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java Wed Aug  5 21:16:47
2009
@@ -22,6 +22,7 @@
 import java.net.InetAddress;
 import java.nio.channels.SelectionKey;
 import java.util.StringTokenizer;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 
@@ -1314,10 +1315,13 @@
             async = true;
         } else if (actionCode == ActionCode.ACTION_ASYNC_COMPLETE) {
           //TODO SERVLET3 - async
+            AtomicBoolean dispatch = (AtomicBoolean)param;
             asyncClose = true;
             RequestInfo rp = request.getRequestProcessor();
-            if ( rp.getStage() != org.apache.coyote.Constants.STAGE_SERVICE ) //async handling
-                socket.getPoller().cometInterest(socket);
+            if ( rp.getStage() != org.apache.coyote.Constants.STAGE_SERVICE ) { //async handling
+                dispatch.set(true);
+                endpoint.processSocket(this.socket, SocketStatus.STOP, true);
+            }
         } else if (actionCode == ActionCode.ACTION_ASYNC_SETTIMEOUT) {
           //TODO SERVLET3 - async
             if (param==null) return;



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


Mime
View raw message