Fix HTTP/2 canceled stream cleanup timing#12673
Open
bneradt wants to merge 1 commit intoapache:masterfrom
Open
Fix HTTP/2 canceled stream cleanup timing#12673bneradt wants to merge 1 commit intoapache:masterfrom
bneradt wants to merge 1 commit intoapache:masterfrom
Conversation
When streams are canceled via RST_STREAM, the stream deletion now happens immediately before the next frame is processed. This prevents the race condition where new HEADERS frames are incorrectly refused because the stream count hasn't been decremented yet. Additionally, when streams are refused due to exceeding max_concurrent_streams, the header blocks are now properly decoded to maintain HPACK dynamic table synchronization per RFC 9113, and RST_STREAM with REFUSED_STREAM is sent instead of terminating the connection with COMPRESSION_ERROR. Fixes: apache#9179
maskit
reviewed
Dec 1, 2025
| // This prevents the race condition where HEADERS frames are incorrectly refused due to the | ||
| // stream count not being decremented yet. The destructor will handle the case where the stream | ||
| // has already been removed from the stream list. | ||
| this->delete_stream(stream); |
Member
There was a problem hiding this comment.
Shouldn't we call THREAD_FREE(stream, http2StreamAllocator, this_ethread()); instead of calling these two, initiating_close and delete_stream?
maskit
reviewed
Dec 1, 2025
| "failed to create temporary stream for header decoding"); | ||
| } | ||
| free_stream_after_decoding = true; | ||
| reset_header_after_decoding = true; |
Member
There was a problem hiding this comment.
Why don't you delete the stream here and return error that probably contains HTTP2_ERROR_REFUSED_STREAM?
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When streams are canceled via RST_STREAM, the stream deletion now happens immediately before the next frame is processed. This prevents the race condition where new HEADERS frames are incorrectly refused because the stream count hasn't been decremented yet. Additionally, when streams are refused due to exceeding max_concurrent_streams, the header blocks are now properly decoded to maintain HPACK dynamic table synchronization per RFC 9113, and RST_STREAM with REFUSED_STREAM is sent instead of terminating the connection with COMPRESSION_ERROR.
Fixes: #9179
I have run this on a machine taking production traffic and it ran fine.