This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Add two missing ConfigureAwait(false) calls in SocketsHttpHandler #29465
Merged
Conversation
This file contains 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
ChunkedTransferEncodingReadStream's ReadAsync had one await missing a ConfigureAwait(false). If there's a synchronization context set on the calling thread, this results in a continuation being created that posts back to that context, which can cause problems (e.g. deadlocks) if that context is blocked, e.g. if the synchronous Read method is being used to block waiting for ReadAsync to complete. The fix is simply to add `.ConfigureAwait(false)`. As long as I was fixing that, I also reviewed all `await`s in SocketsHttpHandler and found one more that was missing `.ConfigureAwait(false)`, in HttpConnectionPool's EstablishProxyTunnel, and so fixed that, too. And added some tests.
geoffkizer
reviewed
May 3, 2018
string response; | ||
switch (chunked) | ||
{ | ||
case false: |
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.
Nit: there's an enum ContentMode
for this in HttpClientHandler_ResponseDrain_Test
, perhaps we should make that a first class thing (i.e., move the enum to LoopbackServer and add overloads that take it)
Or if not for this checkin, perhaps we could file an issue to do this in the future...
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.
Done.
geoffkizer
approved these changes
May 3, 2018
geoffkizer
approved these changes
May 3, 2018
davidsh
approved these changes
May 3, 2018
Thanks for the reviews, @davidsh and @geoffkizer. |
stephentoub
added a commit
to stephentoub/corefx
that referenced
this pull request
May 3, 2018
…tnet#29465) ChunkedTransferEncodingReadStream's ReadAsync had one await missing a ConfigureAwait(false). If there's a synchronization context set on the calling thread, this results in a continuation being created that posts back to that context, which can cause problems (e.g. deadlocks) if that context is blocked, e.g. if the synchronous Read method is being used to block waiting for ReadAsync to complete. The fix is simply to add `.ConfigureAwait(false)`. As long as I was fixing that, I also reviewed all `await`s in SocketsHttpHandler and found one more that was missing `.ConfigureAwait(false)`, in HttpConnectionPool's EstablishProxyTunnel, and so fixed that, too.
stephentoub
added a commit
that referenced
this pull request
May 3, 2018
…9465) (#29470) ChunkedTransferEncodingReadStream's ReadAsync had one await missing a ConfigureAwait(false). If there's a synchronization context set on the calling thread, this results in a continuation being created that posts back to that context, which can cause problems (e.g. deadlocks) if that context is blocked, e.g. if the synchronous Read method is being used to block waiting for ReadAsync to complete. The fix is simply to add `.ConfigureAwait(false)`. As long as I was fixing that, I also reviewed all `await`s in SocketsHttpHandler and found one more that was missing `.ConfigureAwait(false)`, in HttpConnectionPool's EstablishProxyTunnel, and so fixed that, too.
picenka21
pushed a commit
to picenka21/runtime
that referenced
this pull request
Feb 18, 2022
…tnet/corefx#29465) * Add two missing ConfigureAwait(false) calls in SocketsHttpHandler ChunkedTransferEncodingReadStream's ReadAsync had one await missing a ConfigureAwait(false). If there's a synchronization context set on the calling thread, this results in a continuation being created that posts back to that context, which can cause problems (e.g. deadlocks) if that context is blocked, e.g. if the synchronous Read method is being used to block waiting for ReadAsync to complete. The fix is simply to add `.ConfigureAwait(false)`. As long as I was fixing that, I also reviewed all `await`s in SocketsHttpHandler and found one more that was missing `.ConfigureAwait(false)`, in HttpConnectionPool's EstablishProxyTunnel, and so fixed that, too. And added some tests. * Refactor ContentMode support in tests Commit migrated from dotnet/corefx@9e8c200
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.
ChunkedTransferEncodingReadStream's ReadAsync had one await missing a ConfigureAwait(false). If there's a synchronization context set on the calling thread, this results in a continuation being created that posts back to that context, which can cause problems (e.g. deadlocks) if that context is blocked, e.g. if the synchronous Read method is being used to block waiting for ReadAsync to complete. The fix is simply to add
.ConfigureAwait(false)
.As long as I was fixing that, I also reviewed all
await
s in SocketsHttpHandler and found one more that was missing.ConfigureAwait(false)
, in HttpConnectionPool's EstablishProxyTunnel, and so fixed that, too.And added some tests.
Fixes https://github.com/dotnet/corefx/issues/29453
cc: @geoffkizer, @davidsh, @ayende, @pjanotti