-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #5888 - Limit usage of HTTP/2 connections. #12401
Fixes #5888 - Limit usage of HTTP/2 connections. #12401
Conversation
sbordet
commented
Oct 17, 2024
- Made the high-level HttpConnectionOverHTTP2 implement MaxUsable, so it cannot be used to open more streams than allowed.
- Implemented low-level handling of explicit stream ids provided by applications.
- Implemented low-level handling of stream id overflow.
- Added test cases.
* Made the high-level HttpConnectionOverHTTP2 implement MaxUsable, so it cannot be used to open more streams than allowed. * Implemented low-level handling of explicit stream ids provided by applications. * Implemented low-level handling of stream id overflow. * Added test cases. Signed-off-by: Simone Bordet <[email protected]>
Signed-off-by: Ludovic Orban <[email protected]>
Overall, LGTM but these changes introduce a bug caught by |
* Now using a placeholder HTTP2Stream for streams opened with a PRIORITY, but not yet with a HEADERS. Signed-off-by: Simone Bordet <[email protected]>
* Fixed maxUsage check in AbstractConnectionPool. Signed-off-by: Simone Bordet <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry but the algorithm this code is trying to implement is too opaque without comments. I can't say that it is wrong, but it looks very arbitrary, so a bit of explanation would be good.
...src/main/java/org/eclipse/jetty/http2/client/transport/internal/HttpConnectionOverHTTP2.java
Outdated
Show resolved
Hide resolved
...-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java
Outdated
Show resolved
Hide resolved
...-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java
Outdated
Show resolved
Hide resolved
...-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/HTTP2Session.java
Outdated
Show resolved
Hide resolved
Note to self:
|
Now their streams ids are stored in a side Set. Signed-off-by: Simone Bordet <[email protected]>
...ore/jetty-http2/jetty-http2-tests/src/test/java/org/eclipse/jetty/http2/tests/HTTP2Test.java
Show resolved
Hide resolved
Introduced HTTP2Session.maxTotalLocalStreams to limit the max number of streams that might be created in a connection. Linked this new property with the high-level AbstractConnectionPool.maxUsage. Signed-off-by: Simone Bordet <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the new reserveSlot()
logic deserves a try at simplifying it as its complexity exploded which made it rather hard to read.
Otherwise the new stream limitation LGTM.
streamId = localStreamIds.getAndAdd(2); | ||
reserved = true; | ||
// Stream id is given. | ||
while (true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a long maze of if
s and else
s in a while
loop that partially duplicates the logic of the enclosing if
branch, and is quite involved to follow.
Can't this be simplified and de-duplicated?
Signed-off-by: Simone Bordet <[email protected]>