-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
net.http: track h2 server connections for idle shutdown once, not per frame #27435
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
Merged
JalonSolov
merged 1 commit into
vlang:master
from
quaesitor-scientiam:fix-h2-server-idle-tracking
Jun 15, 2026
+20
−29
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
When a client negotiates HTTP/2 and
Server.close()runs whilehandler.handle()is still processing a request, this lifetimemark_idleleaves the active connection inidle_conns, solisten_and_serve_tlscallsidle_conns.close_idle()and shuts the fd before the handler can send its response. Previouslyread_idle_frame()unmarked beforedispatch_frame()/run_request(), matching the active-request close behavior covered bytest_server_tls_close_waits_for_active_request; with this change the analogous H2 request fails on graceful shutdown instead of completing.Useful? React with 👍 / 👎.
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.
Correct description of the semantic change — and intentional. The PR body and the comment in
serve()both document this explicitly: "The only semantic change is that an h2 request in flight when the server stops is now interrupted rather than allowed to finish — which is acceptable at shutdown and is not relied on by any caller (the graceful 'wait for the active request' guarantee is HTTP/1.1-only)."The per-frame mark/unmark approach that preserved the finish-in-flight behavior did so at the cost of a shared-mutex lock + O(n) list scan on every frame on every connection — contending one process-wide mutex on the hot reader path for no real benefit, since
close_idlestill interrupts the blocking frame read by shutting the fd regardless. Registering once per lifetime buys back that overhead.The H2 server is also serial (
SETTINGS_MAX_CONCURRENT_STREAMS = 1), so an "in-flight request" here means at most one call tohandler.handle()that may not finish cleanly on shutdown — not a correctness issue for callers (no one awaits H2 request completion acrossServer.close()).test_server_tls_close_waits_for_active_requesttests the H1 guarantee and is unaffected.