Skip to content

Commit

Permalink
HTTP/3: Abort connection on unexpected exception from AcceptStream (#…
Browse files Browse the repository at this point in the history
…37461)

Co-authored-by: James Newton-King <[email protected]>
  • Loading branch information
github-actions[bot] and JamesNK authored Oct 11, 2021
1 parent 27825be commit ef2d247
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,24 @@ public override void Abort(ConnectionAbortedException abortReason)
// Throw error so consumer sees the connection is aborted by peer.
throw new ConnectionResetException(ex.Message, ex);
}
catch (QuicOperationAbortedException)
catch (QuicOperationAbortedException ex)
{
// Shutdown initiated by us.

lock (_shutdownLock)
{
// Connection has been aborted. Throw reason exception.
_abortReason?.Throw();
// This error should only happen when shutdown has been initiated by the server.
// If there is no abort reason and we have this error then the connection is in an
// unexpected state. Abort connection and throw reason error.
if (_abortReason == null)
{
Abort(new ConnectionAbortedException("Unexpected error when accepting stream.", ex));
}

_abortReason!.Throw();
}
}
catch (OperationCanceledException)
{
// Shutdown initiated by us.
Debug.Assert(cancellationToken.IsCancellationRequested, "Error requires cancellation is requested.");

lock (_shutdownLock)
{
Expand Down

0 comments on commit ef2d247

Please sign in to comment.