You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/07/02 14:02:26 UTC

svn commit: r1498896 - in /tomcat/trunk/java/org/apache/coyote: AbstractProtocol.java http11/upgrade/AbstractProcessor.java

Author: markt
Date: Tue Jul  2 12:02:25 2013
New Revision: 1498896

URL: http://svn.apache.org/r1498896
Log:
Upgraded connections need to be marked as upgraded earlier so any poller events triggered are passed to the upgrade processor.
The call to WebConnection.init() needs to occur after the connection has been marked as upgraded to ensure that any events triggered by the init() code are processed as part of the upgraded connection.

Modified:
    tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java
    tomcat/trunk/java/org/apache/coyote/http11/upgrade/AbstractProcessor.java

Modified: tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java?rev=1498896&r1=1498895&r2=1498896&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java Tue Jul  2 12:02:25 2013
@@ -30,6 +30,7 @@ import javax.management.MBeanServer;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 import javax.servlet.http.HttpUpgradeHandler;
+import javax.servlet.http.WebConnection;
 
 import org.apache.juli.logging.Log;
 import org.apache.tomcat.util.ExceptionUtils;
@@ -636,10 +637,20 @@ public abstract class AbstractProtocol i
                                 processor.getHttpUpgradeHandler();
                         // Release the Http11 processor to be re-used
                         release(wrapper, processor, false, false);
-                        // Create the light-weight upgrade processor
+                        // Create the upgrade processor
                         processor = createUpgradeProcessor(
                                 wrapper, httpUpgradeHandler);
+                        // Mark the connection as upgraded
                         wrapper.setUpgraded(true);
+                        // Associate with the processor with the connection
+                        connections.put(socket, processor);
+                        // Initialise the upgrade handler (which may trigger
+                        // some IO using the new protocol which is why the lines
+                        // above are necessary)
+                        // This cast should be safe. If it fails the error
+                        // handling for the surrounding try/catch will deal with
+                        // it.
+                        httpUpgradeHandler.init((WebConnection) processor);
                     }
                     if (getLog().isDebugEnabled()) {
                         getLog().debug("Socket: [" + wrapper +
@@ -667,8 +678,6 @@ public abstract class AbstractProtocol i
                     connections.remove(socket);
                     release(wrapper, processor, false, false);
                 } else if (state == SocketState.UPGRADED) {
-                    // Need to keep the connection associated with the processor
-                    connections.put(socket, processor);
                     // Don't add sockets back to the poller if this was a
                     // non-blocking write otherwise the poller may trigger
                     // multiple read events which may lead to thread starvation

Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/AbstractProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/AbstractProcessor.java?rev=1498896&r1=1498895&r2=1498896&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/upgrade/AbstractProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/AbstractProcessor.java Tue Jul  2 12:02:25 2013
@@ -48,7 +48,6 @@ public abstract class AbstractProcessor<
         this.httpUpgradeHandler = httpUpgradeHandler;
         this.upgradeServletInputStream = upgradeServletInputStream;
         this.upgradeServletOutputStream = upgradeServletOutputStream;
-        this.httpUpgradeHandler.init(this);
     }
 
 



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