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 2014/08/07 12:28:19 UTC

svn commit: r1616464 - in /tomcat/trunk: java/org/apache/coyote/AbstractProtocol.java java/org/apache/coyote/ContainerThreadMarker.java webapps/docs/changelog.xml

Author: markt
Date: Thu Aug  7 10:28:18 2014
New Revision: 1616464

URL: http://svn.apache.org/r1616464
Log:
Do not mark threads from the container thread pool as container threads when being used to process AsyncContext.start(Runnable)</code> so processing is correctly transferred back to a genuine container thread when necessary.

Modified:
    tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java
    tomcat/trunk/java/org/apache/coyote/ContainerThreadMarker.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java?rev=1616464&r1=1616463&r2=1616464&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java Thu Aug  7 10:28:18 2014
@@ -609,7 +609,7 @@ public abstract class AbstractProtocol<S
             }
 
             wrapper.setAsync(false);
-            ContainerThreadMarker.markAsContainerThread();
+            ContainerThreadMarker.set();
 
             try {
                 if (processor == null) {
@@ -753,7 +753,10 @@ public abstract class AbstractProtocol<S
                 // less-than-verbose logs.
                 getLog().error(
                         sm.getString("abstractConnectionHandler.error"), e);
+            } finally {
+                ContainerThreadMarker.clear();
             }
+
             // Make sure socket/processor is removed from the list of current
             // connections
             connections.remove(socket);

Modified: tomcat/trunk/java/org/apache/coyote/ContainerThreadMarker.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ContainerThreadMarker.java?rev=1616464&r1=1616463&r2=1616464&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ContainerThreadMarker.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ContainerThreadMarker.java Thu Aug  7 10:28:18 2014
@@ -16,6 +16,12 @@
  */
 package org.apache.coyote;
 
+/**
+ * Used to mark threads that have been allocated by the container to process
+ * data from an incoming connection. Application created threads are not
+ * container threads and neither are threads taken from the container thread
+ * pool to execute AsyncContext.start(Runnable).
+ */
 public class ContainerThreadMarker {
 
     private static final ThreadLocal<Boolean> marker = new ThreadLocal<>();
@@ -29,7 +35,11 @@ public class ContainerThreadMarker {
         }
     }
 
-    public static void markAsContainerThread() {
+    public static void set() {
         marker.set(Boolean.TRUE);
     }
+
+    public static void clear() {
+        marker.set(Boolean.FALSE);
+    }
 }

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1616464&r1=1616463&r2=1616464&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Thu Aug  7 10:28:18 2014
@@ -118,6 +118,12 @@
         header is returned for resources that might be returned directly in
         compressed form. (markt)
       </fix>
+      <fix>
+        Do not mark threads from the container thread pool as container threads
+        when being used to process <code>AsyncContext.start(Runnable)</code> so
+        processing is correctly transferred back to a genuine container thread
+        when necessary. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">



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