Fix race condition when cancelling pending HTTP connection attempts#110744
Merged
MihaZupan merged 2 commits intodotnet:mainfrom Dec 18, 2024
Merged
Fix race condition when cancelling pending HTTP connection attempts#110744MihaZupan merged 2 commits intodotnet:mainfrom
MihaZupan merged 2 commits intodotnet:mainfrom
Conversation
Member
Author
|
/azp run runtime-libraries-coreclr outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
3 tasks
Member
Author
|
/backport to release/9.0-staging |
Contributor
|
Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/12364986878 |
MihaZupan
commented
Dec 17, 2024
| response.Dispose(); | ||
| BlocklistAuthority(connection.Authority); | ||
| continue; | ||
| http3ConnectionWaiter?.CancelIfNecessary(this, cancellationToken.IsCancellationRequested); |
Member
Author
There was a problem hiding this comment.
With HTTP 1 and 2, we do this here instead:
antonfirsov
reviewed
Dec 17, 2024
.../System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/HttpConnectionPool.cs
Outdated
Show resolved
Hide resolved
antonfirsov
reviewed
Dec 17, 2024
.../System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/HttpConnectionPool.cs
Outdated
Show resolved
Hide resolved
antonfirsov
approved these changes
Dec 17, 2024
Contributor
antonfirsov
left a comment
There was a problem hiding this comment.
LGTM modulo nitpicking comments above.
antonfirsov
approved these changes
Dec 18, 2024
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #110598
There's a race condition here where if the initiating request completes right away, before we're able to set the
CTSinInjectNewHttp11ConnectionAsync, we'll never set the timeout.runtime/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/HttpConnectionWaiter.cs
Lines 78 to 93 in c969265
runtime/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/HttpConnectionPool.Http1.cs
Lines 256 to 263 in c969265
It's easy to reproduce if you add a delay between the
Yieldand assigning thects, while failing the request.The test I added was 100% deterministic if I added the delay, or increased the
Parallelcount from 100 to 1000, but that takes too long to run for CI.The HTTP/3 change is just adding a try/finally to signal the waiter, looks like we missed that in #101531.
Diff without whitespace changes