Skip to content

Commit

Permalink
Fixed unused methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
ManickaP committed Apr 25, 2024
1 parent 65ea0d8 commit e193fce
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,57 +229,6 @@ private void CheckForHttp3ConnectionInjection()
}
}

[SupportedOSPlatform("windows")]
[SupportedOSPlatform("linux")]
[SupportedOSPlatform("macos")]
private async ValueTask<Http3Connection> CreateHttp3ConnectionAsync(HttpRequestMessage request, HttpAuthority authority, CancellationToken cancellationToken)
{
Debug.Assert(IsHttp3Supported());

if (NetEventSource.Log.IsEnabled())
{
Trace("Attempting new HTTP3 connection.");
}

QuicConnection quicConnection;
try
{
if (IsAltSvcBlocked(authority, out Exception? reasonException))
{
ThrowGetVersionException(request, 3, reasonException);
}
quicConnection = await ConnectHelper.ConnectQuicAsync(request, new DnsEndPoint(authority.IdnHost, authority.Port), _poolManager.Settings._pooledConnectionIdleTimeout, _sslOptionsHttp3!, cancellationToken).ConfigureAwait(false);
}
catch (Exception ex)
{
if (NetEventSource.Log.IsEnabled()) Trace($"QUIC connection failed: {ex}");

// Block list authority only if the connection attempt was not cancelled.
if (ex is not OperationCanceledException oce || !cancellationToken.IsCancellationRequested || oce.CancellationToken != cancellationToken)
{
// Disables HTTP/3 until server announces it can handle it via Alt-Svc.
BlocklistAuthority(authority, ex);
}
throw;
}

if (quicConnection.NegotiatedApplicationProtocol != SslApplicationProtocol.Http3)
{
BlocklistAuthority(authority);
throw new HttpRequestException(HttpRequestError.ConnectionError, "QUIC connected but no HTTP/3 indicated via ALPN.", null, RequestRetryType.RetryOnConnectionFailure);
}

// if the authority was sent as an option through alt-svc then include alt-used header
Http3Connection http3Connection = new Http3Connection(this, authority, quicConnection, includeAltUsedHeader: _http3Authority == authority);

if (NetEventSource.Log.IsEnabled())
{
Trace("New HTTP3 connection established.");
}

return http3Connection;
}

[SupportedOSPlatformGuard("linux")]
[SupportedOSPlatformGuard("macOS")]
[SupportedOSPlatformGuard("Windows")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,14 @@ public bool CleanCacheAndDisposeIfUnused()
// Note: Http11 connections will decrement the _associatedHttp11ConnectionCount when disposed.
// Http2 connections will not, hence the difference in handing _associatedHttp2ConnectionCount.
}
if (_availableHttp3Connections is not null)
{
int removed = ScavengeHttp3ConnectionList(_availableHttp3Connections, ref toDispose, nowTicks, pooledConnectionLifetime, pooledConnectionIdleTimeout);
_associatedHttp3ConnectionCount -= removed;

// Note: Http11 connections will decrement the _associatedHttp11ConnectionCount when disposed.
// Http3 connections will not, hence the difference in handing _associatedHttp3ConnectionCount.
}
}

// Dispose the stale connections outside the pool lock, to avoid holding the lock too long.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,17 @@ public void RemoveStream(QuicStream stream)
}
}

public override long GetIdleTicks(long nowTicks) => throw new NotImplementedException("We aren't scavenging HTTP3 connections yet");
public override long GetIdleTicks(long nowTicks)
{
// The pool is holding the lock as part of its scavenging logic.
// We must not lock on Http2Connection.SyncObj here as that could lead to lock ordering problems.
Debug.Assert(_pool.HasSyncObjLock);

// There is a race condition here where the connection pool may see this connection as idle right before
// we start processing a new request and start its disposal. This is okay as we will either
// return false from TryReserveStream, or process pending requests before tearing down the transport.
return _activeRequests.Count == 0 && _reservedStreams == 0 ? base.GetIdleTicks(nowTicks) : 0;
}

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

0 comments on commit e193fce

Please sign in to comment.