Check _abortException before checking _shutdown flag (#56552)
authorAlexander Nikolaev <55398552+alnikola@users.noreply.github.com>
Fri, 30 Jul 2021 12:21:00 +0000 (14:21 +0200)
committerGitHub <noreply@github.com>
Fri, 30 Jul 2021 12:21:00 +0000 (14:21 +0200)
commitfacbdce3f7e075e8dc2e2a3eed1183ded333ec67
tree1c8e81bf1eb02598328b6085c88e780e8b515802
parentc1185726b999dbfffb8f78d402be2b852a3cb6c4
Check _abortException before checking _shutdown flag (#56552)

In case of an error aborting the connection, there is a race between a thread creating new `Http2Stream` to send a request and the thread looping in `ProcessIncomingFrames` that sets _shutdown flag and `_abortException`. If the request thread first sees `_shutdown == true`, then it won't see the `_abortException` even if it's set, so the request will be retried when it shouldn't.

This PR adds `_abortException` check just before the `_shutdown == true` check to make sure an abort exception is observed.

Fixes #1581
Fixes #56138
Fixes #56026
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http2.cs