This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push: new 10443575cf Refactor to reduce pinning in HTTP/2 code when using virtual threads 10443575cf is described below commit 10443575cfa1740e72002ac28281d4ea3b3af24c Author: Mark Thomas <ma...@apache.org> AuthorDate: Wed Jul 26 10:34:38 2023 +0100 Refactor to reduce pinning in HTTP/2 code when using virtual threads --- java/org/apache/coyote/http2/StreamProcessor.java | 10 ++++++++-- webapps/docs/changelog.xml | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/java/org/apache/coyote/http2/StreamProcessor.java b/java/org/apache/coyote/http2/StreamProcessor.java index 80c04ed5cc..6d4f4b90b4 100644 --- a/java/org/apache/coyote/http2/StreamProcessor.java +++ b/java/org/apache/coyote/http2/StreamProcessor.java @@ -21,6 +21,8 @@ import java.util.Enumeration; import java.util.HashSet; import java.util.Iterator; import java.util.Set; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; import javax.servlet.http.HttpServletResponse; @@ -53,6 +55,7 @@ class StreamProcessor extends AbstractProcessor { private static final Set<String> H2_PSEUDO_HEADERS_REQUEST = new HashSet<>(); + private final Lock processLock = new ReentrantLock(); private final Http2UpgradeHandler handler; private final Stream stream; @@ -74,8 +77,9 @@ class StreamProcessor extends AbstractProcessor { final void process(SocketEvent event) { try { - // FIXME: the regular processor syncs on socketWrapper, but here this deadlocks - synchronized (this) { + // Note: The regular processor uses the socketWrapper lock, but using that here triggers a deadlock + processLock.lock(); + try { // HTTP/2 equivalent of AbstractConnectionHandler#process() without the // socket <-> processor mapping SocketState state = SocketState.CLOSED; @@ -131,6 +135,8 @@ class StreamProcessor extends AbstractProcessor { recycle(); } } + } finally { + processLock.unlock(); } } finally { handler.executeQueuedStream(); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 4f8ad42151..0d5be9f071 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -126,6 +126,10 @@ <code>certificateKeystoreFile</code> attribute of an <code>SSLHostConfigCertificate</code> instance. (markt) </fix> + <scode> + Refactor HTTP/2 implementation to reduce pinning when using virtual + threads. (markt) + </scode> </changelog> </subsection> <subsection name="WebSocket"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org