This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push: new 1f32463d31 Fix 66530 - Regression in fix for BZ 66442. Ensure count is decremented 1f32463d31 is described below commit 1f32463d313b9e764873eb89079cbf24ee863c43 Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Mar 17 09:23:05 2023 +0000 Fix 66530 - Regression in fix for BZ 66442. Ensure count is decremented https://bz.apache.org/bugzilla/show_bug.cgi?id=66530 --- .../apache/coyote/http2/Http2AsyncUpgradeHandler.java | 17 ++++------------- java/org/apache/coyote/http2/Http2UpgradeHandler.java | 15 ++++++++++----- webapps/docs/changelog.xml | 7 +++++++ 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java b/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java index 629924e02e..5eee67451c 100644 --- a/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java +++ b/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java @@ -203,7 +203,7 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler { } } if (endOfStream) { - stream.sentEndOfStream(); + sentEndOfStream(stream); } } @@ -227,10 +227,7 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler { header[3] = FrameType.DATA.getIdByte(); if (finished) { header[4] = FLAG_END_OF_STREAM; - stream.sentEndOfStream(); - if (!stream.isActive()) { - setConnectionTimeoutForStreamCount(activeRemoteStreamCount.decrementAndGet()); - } + sentEndOfStream(stream); } if (writable) { ByteUtil.set31Bits(header, 5, stream.getIdAsInt()); @@ -350,10 +347,7 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler { header[3] = FrameType.DATA.getIdByte(); if (finished) { header[4] = FLAG_END_OF_STREAM; - sendfile.stream.sentEndOfStream(); - if (!sendfile.stream.isActive()) { - setConnectionTimeoutForStreamCount(activeRemoteStreamCount.decrementAndGet()); - } + sentEndOfStream(sendfile.stream); } if (writable) { if (log.isDebugEnabled()) { @@ -434,10 +428,7 @@ public class Http2AsyncUpgradeHandler extends Http2UpgradeHandler { header[3] = FrameType.DATA.getIdByte(); if (finished) { header[4] = FLAG_END_OF_STREAM; - sendfile.stream.sentEndOfStream(); - if (!sendfile.stream.isActive()) { - setConnectionTimeoutForStreamCount(activeRemoteStreamCount.decrementAndGet()); - } + sentEndOfStream(sendfile.stream); } if (writable) { if (log.isDebugEnabled()) { diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java b/java/org/apache/coyote/http2/Http2UpgradeHandler.java index cdd704f603..6e0343689f 100644 --- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java +++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java @@ -707,7 +707,7 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH } stream.sentHeaders(); if (endOfStream) { - stream.sentEndOfStream(); + sentEndOfStream(stream); } } @@ -812,10 +812,7 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH header[3] = FrameType.DATA.getIdByte(); if (finished) { header[4] = FLAG_END_OF_STREAM; - stream.sentEndOfStream(); - if (!stream.isActive()) { - setConnectionTimeoutForStreamCount(activeRemoteStreamCount.decrementAndGet()); - } + sentEndOfStream(stream); } if (writable) { ByteUtil.set31Bits(header, 5, stream.getIdAsInt()); @@ -836,6 +833,14 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH } + protected void sentEndOfStream(Stream stream) { + stream.sentEndOfStream(); + if (!stream.isActive()) { + setConnectionTimeoutForStreamCount(activeRemoteStreamCount.decrementAndGet()); + } + } + + /* * Handles an I/O error on the socket underlying the HTTP/2 connection when it is triggered by application code * (usually reading the request or writing the response). Such I/O errors are fatal so the connection is closed. The diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 46b8da05be..cdfcd7571c 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -174,6 +174,13 @@ <bug>66512</bug>: Align AJP handling of invalid HTTP response headers (they are now removed from the response) with HTTP. (markt) </fix> + <fix> + <bug>66530</bug>: Correct a regression in the fix for bug + <bug>66442</bug> that meant that streams without a response body did not + decrement the active stream count when completing leading to + <code>ERR_HTTP2_SERVER_REFUSED_STREAM</code> for some connections. + (markt) + </fix> </changelog> </subsection> <subsection name="WebSocket"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org