This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new ec18c92086 Fix 66530 - Regression in fix for BZ 66442. Ensure count is
decremented
ec18c92086 is described below
commit ec18c92086258ac22889e88a6d1b3b04b49b8ce1
Author: Mark Thomas <[email protected]>
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 2a5efb9284..fdca5b6275 100644
--- a/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2AsyncUpgradeHandler.java
@@ -202,7 +202,7 @@ public class Http2AsyncUpgradeHandler extends
Http2UpgradeHandler {
}
}
if (endOfStream) {
- stream.sentEndOfStream();
+ sentEndOfStream(stream);
}
}
@@ -226,10 +226,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());
@@ -349,10 +346,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()) {
@@ -433,10 +427,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 de1068b995..1a99048395 100644
--- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
@@ -693,7 +693,7 @@ class Http2UpgradeHandler extends AbstractStream implements
InternalHttpUpgradeH
}
stream.sentHeaders();
if (endOfStream) {
- stream.sentEndOfStream();
+ sentEndOfStream(stream);
}
}
@@ -798,10 +798,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());
@@ -821,6 +818,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 4d86d13214..f81ec47f17 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -160,6 +160,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: [email protected]
For additional commands, e-mail: [email protected]