Skip to content
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

fix issue where HTTP/1.1 connections were not being created asynchronously #56966

Merged
merged 2 commits into from
Aug 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ private async Task AddHttp11ConnectionAsync(HttpRequestMessage request)
{
try
{
connection = await CreateHttp11ConnectionAsync(request, false, cts.Token).ConfigureAwait(false);
connection = await CreateHttp11ConnectionAsync(request, true, cts.Token).ConfigureAwait(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would this work for the Sync HttpClient? I did not see any AddHttp11Connection counterpart.
This is not my area but I was under impression that we want to do alway sync operations for the sync client and async for "normal" case. Having the value fixed makes me wonder....

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only call site to this method is just queueing it via a Task.Run, so there won't ever be a sync caller.

However, this does raise the point that I think Geoff's previous change around connection pooling does mean that we're never creating connections synchronously when we used to, which has a couple ramifications we should consider. First, it means every socket on Unix will be in a non-blocking state, which will make the synchronous operations performed on that connection more expensive. Second, it means that some number of sync requests will be done sync-over-async as they synchronously block waiting for a connection to be available, whereas previously they would have actually been creating the connection synchronously.

}
catch (OperationCanceledException oce) when (oce.CancellationToken == cts.Token)
{
Expand Down Expand Up @@ -607,7 +607,7 @@ private async Task HandleHttp11Downgrade(HttpRequestMessage request, Socket? soc
try
{
// Note, the same CancellationToken from the original HTTP2 connection establishment still applies here.
http11Connection = await ConstructHttp11ConnectionAsync(false, socket, stream, transportContext, request, cancellationToken).ConfigureAwait(false);
http11Connection = await ConstructHttp11ConnectionAsync(true, socket, stream, transportContext, request, cancellationToken).ConfigureAwait(false);
}
catch (OperationCanceledException oce) when (oce.CancellationToken == cancellationToken)
{
Expand All @@ -632,7 +632,7 @@ private async Task AddHttp2ConnectionAsync(HttpRequestMessage request)
{
try
{
(Socket? socket, Stream stream, TransportContext? transportContext) = await ConnectAsync(request, false, cts.Token).ConfigureAwait(false);
(Socket? socket, Stream stream, TransportContext? transportContext) = await ConnectAsync(request, true, cts.Token).ConfigureAwait(false);

if (IsSecure)
{
Expand Down