Skip to content

Commit ffbe1db

Browse files
authored
Throw OperationCanceledException with correct CancellationToken during QuicConnection cancellation (#95459)
1 parent 3805c17 commit ffbe1db

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/libraries/System.Net.Quic/src/System/Net/Quic/QuicConnection.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,14 @@ static async ValueTask<QuicConnection> StartConnectAsync(QuicClientConnectionOpt
7878
{
7979
await connection.FinishConnectAsync(options, linkedCts.Token).ConfigureAwait(false);
8080
}
81-
catch (OperationCanceledException) when (!cancellationToken.IsCancellationRequested)
81+
catch (OperationCanceledException)
8282
{
83-
// handshake timeout elapsed, tear down the connection.
84-
// Note that since handshake is not done yet, application error code is not sent.
8583
await connection.DisposeAsync().ConfigureAwait(false);
8684

85+
// throw OCE with correct token if cancellation requested by user
86+
cancellationToken.ThrowIfCancellationRequested();
87+
88+
// cancellation by the linkedCts.CancelAfter. Convert to Timeout
8789
throw new QuicException(QuicError.ConnectionTimeout, null, SR.Format(SR.net_quic_handshake_timeout, options.HandshakeTimeout));
8890
}
8991
catch

0 commit comments

Comments
 (0)