From 0f473294a761145acf5be5c0e9329f0b09659ad7 Mon Sep 17 00:00:00 2001 From: ManickaP Date: Sat, 23 Jul 2022 10:58:14 +0200 Subject: [PATCH 1/2] Return connection dipose in H3loopback connection --- .../System/Net/Http/Http3LoopbackConnection.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/libraries/Common/tests/System/Net/Http/Http3LoopbackConnection.cs b/src/libraries/Common/tests/System/Net/Http/Http3LoopbackConnection.cs index 953c912114c0f6..b34a64074120d3 100644 --- a/src/libraries/Common/tests/System/Net/Http/Http3LoopbackConnection.cs +++ b/src/libraries/Common/tests/System/Net/Http/Http3LoopbackConnection.cs @@ -69,19 +69,20 @@ public override async ValueTask DisposeAsync() 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(); + await _connection.DisposeAsync(); // Dispose control streams so that we release their handles too. - await _inboundControlStream?.DisposeAsync().ConfigureAwait(false); - await _outboundControlStream?.DisposeAsync().ConfigureAwait(false); -#endif + if (_inboundControlStream is not null) + { + await _inboundControlStream.DisposeAsync().ConfigureAwait(false); + } + if (_outboundControlStream is not null) + { + await _outboundControlStream.DisposeAsync().ConfigureAwait(false); + } } public Task CloseAsync(long errorCode) => _connection.CloseAsync(errorCode).AsTask(); From fbf7fd2aa9f03b28971bc3c81e127e22de644409 Mon Sep 17 00:00:00 2001 From: ManickaP Date: Sun, 24 Jul 2022 10:52:30 +0200 Subject: [PATCH 2/2] Fixed QuicError --- .../System.Net.Quic/tests/FunctionalTests/MsQuicTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Net.Quic/tests/FunctionalTests/MsQuicTests.cs b/src/libraries/System.Net.Quic/tests/FunctionalTests/MsQuicTests.cs index ea127c52c7a06a..afcb2951b96611 100644 --- a/src/libraries/System.Net.Quic/tests/FunctionalTests/MsQuicTests.cs +++ b/src/libraries/System.Net.Quic/tests/FunctionalTests/MsQuicTests.cs @@ -625,7 +625,7 @@ public async Task SetListenerTimeoutWorksWithSmallTimeout() }; (QuicConnection clientConnection, QuicConnection serverConnection) = await CreateConnectedQuicConnection(null, listenerOptions); - await AssertThrowsQuicExceptionAsync(QuicError.ConnectionAborted, async () => await serverConnection.AcceptInboundStreamAsync().AsTask().WaitAsync(TimeSpan.FromSeconds(100))); + await AssertThrowsQuicExceptionAsync(QuicError.ConnectionIdle, async () => await serverConnection.AcceptInboundStreamAsync().AsTask().WaitAsync(TimeSpan.FromSeconds(100))); await serverConnection.DisposeAsync(); await clientConnection.DisposeAsync(); }