diff --git a/build/dependencies.props b/build/dependencies.props index 8691d498a5..36524c989a 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -17,7 +17,7 @@ 2.1.0-preview2-30220 2.1.0-preview2-30220 2.1.0-preview2-30220 - 2.1.0-preview2-30220 + 2.1.0-preview2-pk-corefx0-16426 2.1.0-preview2-30220 2.1.0-preview2-30220 2.1.0-preview2-30220 @@ -29,17 +29,17 @@ 1.1.0 2.1.0-preview2-30220 2.0.0 - 2.1.0-preview2-26225-03 + 2.1.0-preview2-26308-01 2.1.0-preview2-30220 15.6.0 7.0.0 - 4.5.0-preview2-26224-02 - 4.5.0-preview2-26224-02 + 4.5.0-preview2-26308-02 + 4.5.0-preview2-26308-02 6.1.7601.17515 - 4.5.0-preview2-26224-02 - 4.5.0-preview2-26224-02 - 4.5.0-preview2-26224-02 - 4.5.0-preview2-26224-02 + 4.5.0-preview2-26308-02 + 4.5.0-preview2-26308-02 + 4.5.0-preview2-26308-02 + 4.5.0-preview2-26308-02 2.3.1 2.4.0-beta.1.build3945 diff --git a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/OutputProducer.cs b/src/Microsoft.AspNetCore.Server.IISIntegration/Server/OutputProducer.cs index b0de146f11..f956d4bfb7 100644 --- a/src/Microsoft.AspNetCore.Server.IISIntegration/Server/OutputProducer.cs +++ b/src/Microsoft.AspNetCore.Server.IISIntegration/Server/OutputProducer.cs @@ -16,6 +16,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration // This locks access to to all of the below fields private readonly object _contextLock = new object(); + private ValueTask _flushTask; private bool _completed = false; private readonly Pipe _pipe; @@ -99,7 +100,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration return FlushAsyncAwaited(awaitable, cancellationToken); } - private async Task FlushAsyncAwaited(PipeAwaiter awaitable, CancellationToken cancellationToken) + private async Task FlushAsyncAwaited(ValueTask awaitable, CancellationToken cancellationToken) { // https://github.com/dotnet/corefxlab/issues/1334 // Since the flush awaitable doesn't currently support multiple awaiters @@ -107,21 +108,42 @@ namespace Microsoft.AspNetCore.Server.IISIntegration // All awaiters get the same task lock (_flushLock) { + _flushTask = awaitable; if (_flushTcs == null || _flushTcs.Task.IsCompleted) { _flushTcs = new TaskCompletionSource(); - awaitable.OnCompleted(_flushCompleted); + + _flushTask.GetAwaiter().OnCompleted(_flushCompleted); } } - await _flushTcs.Task; - - cancellationToken.ThrowIfCancellationRequested(); + try + { + await _flushTcs.Task; + cancellationToken.ThrowIfCancellationRequested(); + } + catch (OperationCanceledException) + { + _completed = true; + throw; + } } private void OnFlushCompleted() { - _flushTcs.TrySetResult(null); + try + { + _flushTask.GetAwaiter().GetResult(); + _flushTcs.TrySetResult(null); + } + catch (Exception exception) + { + _flushTcs.TrySetResult(exception); + } + finally + { + _flushTask = default; + } } } }