Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetHttp2ConnectionAsync()

async ValueTask< Http2Connection > System.Net.Http.HttpConnectionPool.GetHttp2ConnectionAsync ( HttpRequestMessage request,
bool async,
CancellationToken cancellationToken )
inlineprivate

Definition at line 591 of file HttpConnectionPool.cs.

592 {
594 while (true)
595 {
596 Http2Connection http2Connection;
597 lock (SyncObj)
598 {
600 if (!_http2Enabled)
601 {
602 return null;
603 }
604 int num = _availableHttp2Connections?.Count ?? 0;
605 if (num > 0)
606 {
608 goto IL_0099;
609 }
612 }
613 break;
614 IL_0099:
616 {
617 if (System.Net.NetEventSource.Log.IsEnabled())
618 {
619 http2Connection.Trace("Found expired HTTP/2 connection in pool.", "GetHttp2ConnectionAsync");
620 }
622 continue;
623 }
624 if (!http2Connection.TryReserveStream())
625 {
626 if (System.Net.NetEventSource.Log.IsEnabled())
627 {
628 http2Connection.Trace("Found HTTP/2 connection in pool without available streams.", "GetHttp2ConnectionAsync");
629 }
630 bool flag = false;
631 lock (SyncObj)
632 {
634 if (num2 != -1)
635 {
636 flag = true;
638 }
639 }
640 if (flag)
641 {
643 }
644 continue;
645 }
646 if (System.Net.NetEventSource.Log.IsEnabled())
647 {
648 http2Connection.Trace("Found usable HTTP/2 connection in pool.", "GetHttp2ConnectionAsync");
649 }
650 return http2Connection;
651 }
652 if (System.Net.NetEventSource.Log.IsEnabled())
653 {
654 Trace("No available HTTP/2 connections; request queued.", "GetHttp2ConnectionAsync");
655 }
657 try
658 {
659 return await taskCompletionSourceWithCancellation.WaitWithCancellationAsync(async, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
660 }
661 finally
662 {
663 if (HttpTelemetry.Log.IsEnabled())
664 {
665 HttpTelemetry.Log.Http20RequestLeftQueue(stopwatch.GetElapsedTime().TotalMilliseconds);
666 }
667 }
668 }
RequestQueue< Http2Connection > _http2RequestQueue
List< Http2Connection > _availableHttp2Connections
bool CheckExpirationOnGet(HttpConnectionBase connection)
void InvalidateHttp2Connection(Http2Connection connection)
void Trace(string message, [CallerMemberName] string memberName=null)
void DisableHttp2Connection(Http2Connection connection)
static readonly System.Net.NetEventSource Log
static Microsoft.Extensions.Internal.ValueStopwatch StartNew()

References System.Net.Http.HttpConnectionPool._availableHttp2Connections, System.Net.Http.HttpConnectionPool._http2Enabled, System.Net.Http.HttpConnectionPool._http2RequestQueue, System.Net.Http.HttpConnectionPool._usedSinceLastCleanup, System.cancellationToken, System.Net.Http.HttpConnectionPool.CheckExpirationOnGet(), System.Net.Http.HttpConnectionPool.CheckForHttp2ConnectionInjection(), System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Net.Http.HttpConnectionPool.DisableHttp2Connection(), System.Net.Http.HttpConnectionPool.InvalidateHttp2Connection(), System.Net.Http.HttpTelemetry.Log, System.Net.NetEventSource.Log, Microsoft.Extensions.Internal.ValueStopwatch.StartNew(), System.Net.Http.HttpConnectionPool.SyncObj, and System.Net.Http.HttpConnectionPool.Trace().

Referenced by System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync().