Author: markt
Date: Tue Aug 14 15:26:21 2018
New Revision: 1838028
URL: http://svn.apache.org/viewvc?rev=1838028&view=rev
Log:
Fix deadlock issues identified while investigating
https://bz.apache.org/bugzilla/show_bug.cgi?id=62620
Modified:
tomcat/trunk/java/org/apache/coyote/http2/StreamProcessor.java
tomcat/trunk/webapps/docs/changelog.xml
Modified: tomcat/trunk/java/org/apache/coyote/http2/StreamProcessor.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http2/StreamProcessor.java?rev=1838028&r1=1838027&r2=1838028&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http2/StreamProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http2/StreamProcessor.java Tue Aug 14
15:26:21 2018
@@ -255,15 +255,25 @@ class StreamProcessor extends AbstractPr
@Override
protected final void executeDispatches() {
Iterator<DispatchType> dispatches = getIteratorAndClearDispatches();
- synchronized (this) {
+ /*
+ * Compare with superclass that uses SocketWrapper
+ * A sync is not necessary here as the window sizes are updated with
+ * syncs before the dispatches are executed and it is the window size
+ * updates that need to be complete before the dispatch executes.
+ */
+ while (dispatches != null && dispatches.hasNext()) {
+ DispatchType dispatchType = dispatches.next();
/*
- * TODO Check if this sync is necessary.
- * Compare with superclass that uses SocketWrapper
+ * Dispatch on new thread.
+ * Firstly, this avoids a deadlock on the SocketWrapper as Streams
+ * being processed by container threads lock the SocketProcessor
+ * before they lock the SocketWrapper which is the opposite order
to
+ * container threads processing via Http2UpgrageHandler.
+ * Secondly, this code executes after a Window update has released
+ * one or more Streams. By dispatching each Stream to a dedicated
+ * thread, those Streams may progress concurrently.
*/
- while (dispatches != null && dispatches.hasNext()) {
- DispatchType dispatchType = dispatches.next();
- processSocketEvent(dispatchType.getSocketStatus(), false);
- }
+ processSocketEvent(dispatchType.getSocketStatus(), true);
}
}
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1838028&r1=1838027&r2=1838028&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Tue Aug 14 15:26:21 2018
@@ -45,6 +45,12 @@
issues do not "pop up" wrt. others).
-->
<section name="Tomcat 9.0.12 (markt)" rtext="in development">
+ <subsection name="Coyote">
+ <changelog>
+ Fix potential deadlocks when using asynchronous Servlet processing with
+ HTTP/2 connectors. (markt)
+ </changelog>
+ </subsection>
<subsection name="Other">
<changelog>
<fix>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]