Skip to content

Commit e193fce

Browse files
committed
Fixed unused methods.
1 parent 65ea0d8 commit e193fce

3 files changed

Lines changed: 19 additions & 52 deletions

File tree

src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/HttpConnectionPool.Http3.cs

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -229,57 +229,6 @@ private void CheckForHttp3ConnectionInjection()
229229
}
230230
}
231231

232-
[SupportedOSPlatform("windows")]
233-
[SupportedOSPlatform("linux")]
234-
[SupportedOSPlatform("macos")]
235-
private async ValueTask<Http3Connection> CreateHttp3ConnectionAsync(HttpRequestMessage request, HttpAuthority authority, CancellationToken cancellationToken)
236-
{
237-
Debug.Assert(IsHttp3Supported());
238-
239-
if (NetEventSource.Log.IsEnabled())
240-
{
241-
Trace("Attempting new HTTP3 connection.");
242-
}
243-
244-
QuicConnection quicConnection;
245-
try
246-
{
247-
if (IsAltSvcBlocked(authority, out Exception? reasonException))
248-
{
249-
ThrowGetVersionException(request, 3, reasonException);
250-
}
251-
quicConnection = await ConnectHelper.ConnectQuicAsync(request, new DnsEndPoint(authority.IdnHost, authority.Port), _poolManager.Settings._pooledConnectionIdleTimeout, _sslOptionsHttp3!, cancellationToken).ConfigureAwait(false);
252-
}
253-
catch (Exception ex)
254-
{
255-
if (NetEventSource.Log.IsEnabled()) Trace($"QUIC connection failed: {ex}");
256-
257-
// Block list authority only if the connection attempt was not cancelled.
258-
if (ex is not OperationCanceledException oce || !cancellationToken.IsCancellationRequested || oce.CancellationToken != cancellationToken)
259-
{
260-
// Disables HTTP/3 until server announces it can handle it via Alt-Svc.
261-
BlocklistAuthority(authority, ex);
262-
}
263-
throw;
264-
}
265-
266-
if (quicConnection.NegotiatedApplicationProtocol != SslApplicationProtocol.Http3)
267-
{
268-
BlocklistAuthority(authority);
269-
throw new HttpRequestException(HttpRequestError.ConnectionError, "QUIC connected but no HTTP/3 indicated via ALPN.", null, RequestRetryType.RetryOnConnectionFailure);
270-
}
271-
272-
// if the authority was sent as an option through alt-svc then include alt-used header
273-
Http3Connection http3Connection = new Http3Connection(this, authority, quicConnection, includeAltUsedHeader: _http3Authority == authority);
274-
275-
if (NetEventSource.Log.IsEnabled())
276-
{
277-
Trace("New HTTP3 connection established.");
278-
}
279-
280-
return http3Connection;
281-
}
282-
283232
[SupportedOSPlatformGuard("linux")]
284233
[SupportedOSPlatformGuard("macOS")]
285234
[SupportedOSPlatformGuard("Windows")]

src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/HttpConnectionPool.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,14 @@ public bool CleanCacheAndDisposeIfUnused()
960960
// Note: Http11 connections will decrement the _associatedHttp11ConnectionCount when disposed.
961961
// Http2 connections will not, hence the difference in handing _associatedHttp2ConnectionCount.
962962
}
963+
if (_availableHttp3Connections is not null)
964+
{
965+
int removed = ScavengeHttp3ConnectionList(_availableHttp3Connections, ref toDispose, nowTicks, pooledConnectionLifetime, pooledConnectionIdleTimeout);
966+
_associatedHttp3ConnectionCount -= removed;
967+
968+
// Note: Http11 connections will decrement the _associatedHttp11ConnectionCount when disposed.
969+
// Http3 connections will not, hence the difference in handing _associatedHttp3ConnectionCount.
970+
}
963971
}
964972

965973
// Dispose the stale connections outside the pool lock, to avoid holding the lock too long.

src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,17 @@ public void RemoveStream(QuicStream stream)
426426
}
427427
}
428428

429-
public override long GetIdleTicks(long nowTicks) => throw new NotImplementedException("We aren't scavenging HTTP3 connections yet");
429+
public override long GetIdleTicks(long nowTicks)
430+
{
431+
// The pool is holding the lock as part of its scavenging logic.
432+
// We must not lock on Http2Connection.SyncObj here as that could lead to lock ordering problems.
433+
Debug.Assert(_pool.HasSyncObjLock);
434+
435+
// There is a race condition here where the connection pool may see this connection as idle right before
436+
// we start processing a new request and start its disposal. This is okay as we will either
437+
// return false from TryReserveStream, or process pending requests before tearing down the transport.
438+
return _activeRequests.Count == 0 && _reservedStreams == 0 ? base.GetIdleTicks(nowTicks) : 0;
439+
}
430440

431441
public override void Trace(string message, [CallerMemberName] string? memberName = null) =>
432442
Trace(0, message, memberName);

0 commit comments

Comments
 (0)