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 2022/09/30 19:01:00 UTC
[tomcat] branch 8.5.x updated: BZ 66281 - unexpected timeouts when using HTTP/2 and NIO2
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 b01c241e56 BZ 66281 - unexpected timeouts when using HTTP/2 and NIO2
b01c241e56 is described below
commit b01c241e56cec904d3cd9fa00c9a2bc0b6831bbc
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Sep 30 18:17:14 2022 +0100
BZ 66281 - unexpected timeouts when using HTTP/2 and NIO2
Timeouts may appear as client disconnections
https://bz.apache.org/bugzilla/show_bug.cgi?id=66281
---
java/org/apache/coyote/http2/Http2UpgradeHandler.java | 18 ++++++++++++++----
webapps/docs/changelog.xml | 4 ++++
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
index 80f91b296b..e9d982b95c 100644
--- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
@@ -274,6 +274,10 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH
throw new ProtocolException(sm.getString("upgradeHandler.pingFailed"), ioe);
}
+ // Allow streams and connection to determine timeouts
+ socketWrapper.setReadTimeout(-1);
+ socketWrapper.setWriteTimeout(-1);
+
if (webConnection != null) {
processStreamOnContainerThread(stream);
}
@@ -337,10 +341,7 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH
}
}
try {
- // There is data to read so use the read timeout while
- // reading frames ...
- socketWrapper.setReadTimeout(getReadTimeout());
- // ... and disable the connection timeout
+ // Disable the connection timeout while frames are processed
setConnectionTimeout(-1);
while (true) {
try {
@@ -1603,6 +1604,15 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH
int thisRead = 0;
while (len > 0) {
+ // Blocking reads use the protocol level read timeout. Non-blocking
+ // reads do not timeout. The intention is that once a frame has
+ // started to be read, the read timeout applies until it is
+ // completely read.
+ if (nextReadBlock) {
+ socketWrapper.setReadTimeout(protocol.getReadTimeout());
+ } else {
+ socketWrapper.setReadTimeout(-1);
+ }
thisRead = socketWrapper.read(nextReadBlock, data, pos, len);
if (thisRead == 0) {
if (nextReadBlock) {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 34ac069917..e1da0113de 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -186,6 +186,10 @@
<bug>66276</bug>: Fix incorrect class cast when adding
a descendant of HTTP/2 streams. (lihan)
</fix>
+ <fix>
+ <bug>66281</bug>: Fix unexpected timeouts that may appear as client
+ disconnections when using HTTP/2 and NIO2. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org