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 2020/09/24 14:59:11 UTC
[tomcat] 01/02: Improve handling of HTTP/2 connection preface
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 9083cea2ef8b1bc4a8fdbe5dcd544f4edc204dea
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Sep 24 15:50:35 2020 +0100
Improve handling of HTTP/2 connection preface
Only process the connection if the preface is processed without error.
If an error is detected, trigger the connection close.
---
java/org/apache/coyote/http2/Http2AsyncParser.java | 9 +++++----
webapps/docs/changelog.xml | 5 +++++
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/java/org/apache/coyote/http2/Http2AsyncParser.java b/java/org/apache/coyote/http2/Http2AsyncParser.java
index c76effc..ed565fd 100644
--- a/java/org/apache/coyote/http2/Http2AsyncParser.java
+++ b/java/org/apache/coyote/http2/Http2AsyncParser.java
@@ -35,7 +35,7 @@ class Http2AsyncParser extends Http2Parser {
private final SocketWrapperBase<?> socketWrapper;
private final Http2AsyncUpgradeHandler upgradeHandler;
- private Throwable error = null;
+ private volatile Throwable error = null;
Http2AsyncParser(String connectionId, Input input, Output output, SocketWrapperBase<?> socketWrapper, Http2AsyncUpgradeHandler upgradeHandler) {
super(connectionId, input, output);
@@ -117,13 +117,14 @@ class Http2AsyncParser extends Http2Parser {
if (payload.hasRemaining()) {
socketWrapper.unRead(payload);
}
+ // Finish processing the connection
+ upgradeHandler.processConnectionCallback(webConnection, stream);
+ } else {
+ upgradeHandler.closeConnection(new ConnectionException(error.getMessage(), Http2Error.PROTOCOL_ERROR, error));
}
- // Finish processing the connection
- upgradeHandler.processConnectionCallback(webConnection, stream);
// Continue reading frames
upgradeHandler.upgradeDispatch(SocketEvent.OPEN_READ);
}
-
}
@Override
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 005a046..85b7eee 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -115,6 +115,11 @@
in-flight asynchronous requests. The tracking enables Tomcat to shutdown
gracefully when asynchronous processing is in use. (markt)
</fix>
+ <fix>
+ Improve the error handling for the HTTP/2 connection preface when the
+ Connector is configured with <code>useAsycIO="true"</code>.
+ (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