Skip to content

Commit 915a2f9

Browse files
authored
Add catch for ConnectionAborted in Http3 (#93049)
* Racing between protocol close and abort fix * Add catching for ConnectionAbort in two places * Revert change on test
1 parent 52806bc commit 915a2f9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,13 @@ private async Task SendSettingsAsync()
388388

389389
await _clientControl.WriteAsync(_pool.Settings.Http3SettingsFrame, CancellationToken.None).ConfigureAwait(false);
390390
}
391+
catch (QuicException ex) when (ex.QuicError == QuicError.ConnectionAborted)
392+
{
393+
Debug.Assert(ex.ApplicationErrorCode.HasValue);
394+
Http3ErrorCode code = (Http3ErrorCode)ex.ApplicationErrorCode.Value;
395+
396+
Abort(HttpProtocolException.CreateHttp3ConnectionException(code, SR.net_http_http3_connection_close));
397+
}
391398
catch (Exception ex)
392399
{
393400
Abort(ex);
@@ -577,6 +584,13 @@ private async Task ProcessServerStreamAsync(QuicStream stream)
577584
{
578585
// ignore the exception, we have already closed the connection
579586
}
587+
catch (QuicException ex) when (ex.QuicError == QuicError.ConnectionAborted)
588+
{
589+
Debug.Assert(ex.ApplicationErrorCode.HasValue);
590+
Http3ErrorCode code = (Http3ErrorCode)ex.ApplicationErrorCode.Value;
591+
592+
Abort(HttpProtocolException.CreateHttp3ConnectionException(code, SR.net_http_http3_connection_close));
593+
}
580594
catch (Exception ex)
581595
{
582596
Abort(ex);

0 commit comments

Comments
 (0)