Skip to content

Commit

Permalink
Ensure HTTP/1.1 processor is recycled after a direct h2c connection
Browse files Browse the repository at this point in the history
  • Loading branch information
markt-asf committed Jun 26, 2020
1 parent 2a13558 commit 923d834
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 6 additions & 3 deletions java/org/apache/coyote/AbstractProtocol.java
Expand Up @@ -826,8 +826,10 @@ public SocketState process(SocketWrapperBase<S> wrapper, SocketEvent status) {
// Assume direct HTTP/2 connection
UpgradeProtocol upgradeProtocol = getProtocol().getUpgradeProtocol("h2c");
if (upgradeProtocol != null) {
processor = upgradeProtocol.getProcessor(
wrapper, getProtocol().getAdapter());
// Release the Http11 processor to be re-used
release(processor);
// Create the upgrade processor
processor = upgradeProtocol.getProcessor(wrapper, getProtocol().getAdapter());
wrapper.unRead(leftOverInput);
// Associate with the processor with the connection
connections.put(socket, processor);
Expand All @@ -837,7 +839,8 @@ public SocketState process(SocketWrapperBase<S> wrapper, SocketEvent status) {
"abstractConnectionHandler.negotiatedProcessor.fail",
"h2c"));
}
return SocketState.CLOSED;
// Exit loop and trigger appropriate clean-up
state = SocketState.CLOSED;
}
} else {
HttpUpgradeHandler httpUpgradeHandler = upgradeToken.getHttpUpgradeHandler();
Expand Down
4 changes: 4 additions & 0 deletions webapps/docs/changelog.xml
Expand Up @@ -103,6 +103,10 @@
<fix>
Reduce the memory footprint of closed HTTP/2 streams. (markt)
</fix>
<fix>
Ensure that the HTTP/1.1 processor is correctly recycled when a direct
connection to h2c is made. (markt)
</fix>
</changelog>
</subsection>
<subsection name="Other">
Expand Down

0 comments on commit 923d834

Please sign in to comment.