Set error before changing state in SocketInput.AbortAwaiting

- This fixes a tight race where awaiting code might continue but not see
  the ODE that moved SocketInput into the completed state.
This commit is contained in:
Stephen Halter 2015-12-10 12:21:20 -08:00
parent f42bb02f24
commit f9d70e601c
1 changed files with 2 additions and 1 deletions

View File

@ -180,11 +180,12 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
public void AbortAwaiting()
{
_awaitableError = new ObjectDisposedException(nameof(SocketInput), "The request was aborted");
var awaitableState = Interlocked.Exchange(
ref _awaitableState,
_awaitableIsCompleted);
_awaitableError = new ObjectDisposedException(nameof(SocketInput), "The request was aborted");
_manualResetEvent.Set();
if (awaitableState != _awaitableIsCompleted &&