public override async ValueTask DisposeAsync() { // Close any remaining request streams (but NOT control streams, as these should not be closed while the connection is open) foreach (Http3LoopbackStream stream in _openStreams.Values) { await stream.DisposeAsync().ConfigureAwait(false); } foreach (QuicStream stream in _delayedStreams) { await stream.DisposeAsync().ConfigureAwait(false); } // Dispose the connection // If we already waited for graceful shutdown from the client, then the connection is already closed and this will simply release the handle. // If not, then this will silently abort the connection. await _connection.DisposeAsync(); // Dispose control streams so that we release their handles too. if (_inboundControlStream is not null) { await _inboundControlStream.DisposeAsync().ConfigureAwait(false); } if (_outboundControlStream is not null) { await _outboundControlStream.DisposeAsync().ConfigureAwait(false); } }
public override async ValueTask DisposeAsync() { // Close any remaining request streams (but NOT control streams, as these should not be closed while the connection is open) foreach (Http3LoopbackStream stream in _openStreams.Values) { await stream.DisposeAsync().ConfigureAwait(false); } foreach (QuicStream stream in _delayedStreams) { await stream.DisposeAsync().ConfigureAwait(false); } // We don't dispose the connection currently, because this causes races when the server connection is closed before // the client has received and handled all response data. // See discussion in https://github.com/dotnet/runtime/pull/57223#discussion_r687447832 #if false // Dispose the connection // If we already waited for graceful shutdown from the client, then the connection is already closed and this will simply release the handle. // If not, then this will silently abort the connection. _connection.Dispose(); // Dispose control streams so that we release their handles too. await _inboundControlStream?.DisposeAsync().ConfigureAwait(false); await _outboundControlStream?.DisposeAsync().ConfigureAwait(false); #endif }