Skip to content

Commit

Permalink
Add catch for ConnectionAborted in Http3 (#93049)
Browse files Browse the repository at this point in the history
* Racing between protocol close and abort fix

* Add catching for ConnectionAbort in two places

* Revert change on test
  • Loading branch information
liveans committed Oct 6, 2023
1 parent 52806bc commit 915a2f9
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,13 @@ private async Task SendSettingsAsync()

await _clientControl.WriteAsync(_pool.Settings.Http3SettingsFrame, CancellationToken.None).ConfigureAwait(false);
}
catch (QuicException ex) when (ex.QuicError == QuicError.ConnectionAborted)
{
Debug.Assert(ex.ApplicationErrorCode.HasValue);
Http3ErrorCode code = (Http3ErrorCode)ex.ApplicationErrorCode.Value;

Abort(HttpProtocolException.CreateHttp3ConnectionException(code, SR.net_http_http3_connection_close));
}
catch (Exception ex)
{
Abort(ex);
Expand Down Expand Up @@ -577,6 +584,13 @@ private async Task ProcessServerStreamAsync(QuicStream stream)
{
// ignore the exception, we have already closed the connection
}
catch (QuicException ex) when (ex.QuicError == QuicError.ConnectionAborted)
{
Debug.Assert(ex.ApplicationErrorCode.HasValue);
Http3ErrorCode code = (Http3ErrorCode)ex.ApplicationErrorCode.Value;

Abort(HttpProtocolException.CreateHttp3ConnectionException(code, SR.net_http_http3_connection_close));
}
catch (Exception ex)
{
Abort(ex);
Expand Down

0 comments on commit 915a2f9

Please sign in to comment.