Use non-generic TaskCompletionSource in SignalR and Kestrel (#22925)
This commit is contained in:
parent
a67c217976
commit
49aecc3efe
|
|
@ -66,7 +66,7 @@ namespace RunTests
|
|||
string filename,
|
||||
string arguments,
|
||||
string? workingDirectory = null,
|
||||
string dumpDirectoryPath = null,
|
||||
string? dumpDirectoryPath = null,
|
||||
bool throwOnError = true,
|
||||
IDictionary<string, string?>? environmentVariables = null,
|
||||
Action<string>? outputDataReceived = null,
|
||||
|
|
|
|||
|
|
@ -157,11 +157,11 @@ namespace Microsoft.AspNetCore.Hosting
|
|||
},
|
||||
applicationLifetime);
|
||||
|
||||
var waitForStop = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var waitForStop = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
applicationLifetime.ApplicationStopping.Register(obj =>
|
||||
{
|
||||
var tcs = (TaskCompletionSource<object>)obj;
|
||||
tcs.TrySetResult(null);
|
||||
var tcs = (TaskCompletionSource)obj;
|
||||
tcs.TrySetResult();
|
||||
}, waitForStop);
|
||||
|
||||
await waitForStop.Task;
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
|
|||
AddEnvironmentVariablesToProcess(startInfo, DeploymentParameters.EnvironmentVariables);
|
||||
|
||||
Uri actualUrl = null;
|
||||
var started = new TaskCompletionSource<object>();
|
||||
var started = new TaskCompletionSource();
|
||||
|
||||
HostProcess = new Process() { StartInfo = startInfo };
|
||||
HostProcess.EnableRaisingEvents = true;
|
||||
|
|
@ -148,7 +148,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
|
|||
{
|
||||
if (string.Equals(dataArgs.Data, ApplicationStartedMessage))
|
||||
{
|
||||
started.TrySetResult(null);
|
||||
started.TrySetResult();
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(dataArgs.Data))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
|
|||
private readonly ServiceContext _serviceContext;
|
||||
private readonly Func<T, Task> _connectionDelegate;
|
||||
private readonly TransportConnectionManager _transportConnectionManager;
|
||||
private readonly TaskCompletionSource<object> _acceptLoopTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private readonly TaskCompletionSource _acceptLoopTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
public ConnectionDispatcher(ServiceContext serviceContext, Func<T, Task> connectionDelegate, TransportConnectionManager transportConnectionManager)
|
||||
{
|
||||
|
|
@ -73,7 +73,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
|
|||
}
|
||||
finally
|
||||
{
|
||||
_acceptLoopTcs.TrySetResult(null);
|
||||
_acceptLoopTcs.TrySetResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http3
|
|||
|
||||
private readonly Http3Connection _http3Connection;
|
||||
private bool _receivedHeaders;
|
||||
private TaskCompletionSource<object> _appCompleted;
|
||||
private TaskCompletionSource _appCompleted;
|
||||
|
||||
public Pipe RequestBodyPipe { get; }
|
||||
|
||||
public Http3Stream(Http3Connection http3Connection, Http3StreamContext context)
|
||||
public Http3Stream(Http3Connection http3Connection, Http3StreamContext context)
|
||||
{
|
||||
Initialize(context);
|
||||
|
||||
|
|
@ -307,7 +307,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http3
|
|||
{
|
||||
Debug.Assert(_appCompleted != null);
|
||||
|
||||
_appCompleted.SetResult(new object());
|
||||
_appCompleted.SetResult();
|
||||
}
|
||||
|
||||
private bool TryClose()
|
||||
|
|
@ -457,7 +457,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http3
|
|||
_receivedHeaders = true;
|
||||
InputRemaining = HttpRequestHeaders.ContentLength;
|
||||
|
||||
_appCompleted = new TaskCompletionSource<object>();
|
||||
_appCompleted = new TaskCompletionSource();
|
||||
|
||||
ThreadPool.UnsafeQueueUserWorkItem(this, preferLocal: false);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
|
|||
private bool _completed;
|
||||
|
||||
private readonly CancellationTokenSource _connectionClosingCts = new CancellationTokenSource();
|
||||
private readonly TaskCompletionSource<object> _completionTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private readonly TaskCompletionSource _completionTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
protected readonly long _id;
|
||||
protected readonly ServiceContext _serviceContext;
|
||||
protected readonly TransportConnectionManager _transportConnectionManager;
|
||||
|
|
@ -166,7 +166,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
|
|||
|
||||
public void Complete()
|
||||
{
|
||||
_completionTcs.TrySetResult(null);
|
||||
_completionTcs.TrySetResult();
|
||||
|
||||
_connectionClosingCts.Dispose();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,8 +95,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
|
|||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
var tcs = new TaskCompletionSource<object?>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
token.Register(() => tcs.SetResult(null));
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
token.Register(() => tcs.SetResult());
|
||||
return tcs.Task;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
|
|||
private bool _hasStarted;
|
||||
private int _stopping;
|
||||
private readonly CancellationTokenSource _stopCts = new CancellationTokenSource();
|
||||
private readonly TaskCompletionSource<object> _stoppedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private readonly TaskCompletionSource _stoppedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
private IDisposable _configChangedRegistration;
|
||||
|
||||
|
|
@ -238,7 +238,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
|
|||
_bindSemaphore.Release();
|
||||
}
|
||||
|
||||
_stoppedTcs.TrySetResult(null);
|
||||
_stoppedTcs.TrySetResult();
|
||||
}
|
||||
|
||||
// Ungraceful shutdown
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
Assert.False(flushTask0.IsCompleted);
|
||||
Assert.False(flushTask1.IsCompleted);
|
||||
|
||||
mockPipeWriter.FlushTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
mockPipeWriter.FlushTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
pipeWriterFlushTcsArray[0].SetResult(default);
|
||||
|
||||
await mockPipeWriter.FlushTcs.Task.DefaultTimeout();
|
||||
|
|
@ -141,7 +141,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
Assert.False(flushTask0.IsCompleted);
|
||||
Assert.False(flushTask1.IsCompleted);
|
||||
|
||||
mockPipeWriter.FlushTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
mockPipeWriter.FlushTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
pipeWriterFlushTcsArray[1].SetResult(default);
|
||||
|
||||
await mockPipeWriter.FlushTcs.Task.DefaultTimeout();
|
||||
|
|
@ -235,7 +235,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
Assert.Equal(3, mockPipeWriter.AdvanceCallCount);
|
||||
Assert.Equal(2, mockPipeWriter.FlushCallCount);
|
||||
Assert.False(flushTask1.IsCompleted);
|
||||
|
||||
|
||||
pipeWriterFlushTcsArray[1].SetResult(default);
|
||||
|
||||
await flushTask1.DefaultTimeout();
|
||||
|
|
@ -426,14 +426,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
public int FlushCallCount { get; set; }
|
||||
public int CancelPendingFlushCallCount { get; set; }
|
||||
|
||||
public TaskCompletionSource<object> FlushTcs { get; set; }
|
||||
public TaskCompletionSource FlushTcs { get; set; }
|
||||
|
||||
public Exception CompleteException { get; set; }
|
||||
|
||||
public override ValueTask<FlushResult> FlushAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
FlushCallCount++;
|
||||
FlushTcs?.TrySetResult(null);
|
||||
FlushTcs?.TrySetResult();
|
||||
return new ValueTask<FlushResult>(_flushResults[FlushCallCount - 1].Task);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
{
|
||||
var serviceContext = new TestServiceContext();
|
||||
// This needs to run inline
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var tcs = new TaskCompletionSource();
|
||||
|
||||
var connection = new Mock<DefaultConnectionContext> { CallBase = true }.Object;
|
||||
connection.ConnectionClosed = new CancellationToken(canceled: true);
|
||||
|
|
@ -47,7 +47,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
Assert.True(pairs.ContainsKey("ConnectionId"));
|
||||
Assert.Equal(connection.ConnectionId, pairs["ConnectionId"]);
|
||||
|
||||
tcs.TrySetResult(null);
|
||||
tcs.TrySetResult();
|
||||
|
||||
await task;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,12 +29,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
var debugger = new Mock<IDebugger>();
|
||||
var kestrelTrace = new Mock<IKestrelTrace>();
|
||||
var handlerMre = new ManualResetEventSlim();
|
||||
var handlerStartedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var handlerStartedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var now = systemClock.UtcNow;
|
||||
|
||||
heartbeatHandler.Setup(h => h.OnHeartbeat(now)).Callback(() =>
|
||||
{
|
||||
handlerStartedTcs.SetResult(null);
|
||||
handlerStartedTcs.SetResult();
|
||||
handlerMre.Wait();
|
||||
});
|
||||
debugger.Setup(d => d.IsAttached).Returns(false);
|
||||
|
|
@ -67,12 +67,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
var debugger = new Mock<IDebugger>();
|
||||
var kestrelTrace = new Mock<IKestrelTrace>();
|
||||
var handlerMre = new ManualResetEventSlim();
|
||||
var handlerStartedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var handlerStartedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var now = systemClock.UtcNow;
|
||||
|
||||
heartbeatHandler.Setup(h => h.OnHeartbeat(now)).Callback(() =>
|
||||
{
|
||||
handlerStartedTcs.SetResult(null);
|
||||
handlerStartedTcs.SetResult();
|
||||
handlerMre.Wait();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.IO.Pipelines;
|
||||
|
|
@ -29,14 +29,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
|
||||
var httpConnection = new HttpConnection(httpConnectionContext);
|
||||
|
||||
var aborted = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var aborted = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var http1Connection = new Http1Connection(httpConnectionContext);
|
||||
|
||||
httpConnection.Initialize(http1Connection);
|
||||
http1Connection.Reset();
|
||||
http1Connection.RequestAborted.Register(() =>
|
||||
{
|
||||
aborted.SetResult(null);
|
||||
aborted.SetResult();
|
||||
});
|
||||
|
||||
httpConnection.OnTimeout(TimeoutReason.WriteDataRate);
|
||||
|
|
|
|||
|
|
@ -373,7 +373,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
}
|
||||
};
|
||||
|
||||
var unbindTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var unbindTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
var mockTransport = new Mock<IConnectionListener>();
|
||||
var mockTransportFactory = new Mock<IConnectionListenerFactory>();
|
||||
|
|
@ -411,7 +411,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
stopTask1.Wait();
|
||||
});
|
||||
|
||||
unbindTcs.SetResult(null);
|
||||
unbindTcs.SetResult();
|
||||
|
||||
// If stopTask2 is completed inline by the first call to StopAsync, stopTask1 will never complete.
|
||||
await stopTask1.DefaultTimeout();
|
||||
|
|
@ -467,16 +467,16 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
}).Build();
|
||||
|
||||
Func<Task> changeCallback = null;
|
||||
TaskCompletionSource<object> changeCallbackRegisteredTcs = null;
|
||||
TaskCompletionSource changeCallbackRegisteredTcs = null;
|
||||
|
||||
var mockChangeToken = new Mock<IChangeToken>();
|
||||
mockChangeToken.Setup(t => t.RegisterChangeCallback(It.IsAny<Action<object>>(), It.IsAny<object>())).Returns<Action<object>, object>((callback, state) =>
|
||||
{
|
||||
changeCallbackRegisteredTcs?.SetResult(null);
|
||||
changeCallbackRegisteredTcs?.SetResult();
|
||||
|
||||
changeCallback = () =>
|
||||
{
|
||||
changeCallbackRegisteredTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
changeCallbackRegisteredTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
callback(state);
|
||||
return changeCallbackRegisteredTcs.Task;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -859,11 +859,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
{
|
||||
using (var input = new TestInput())
|
||||
{
|
||||
var logEvent = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var logEvent = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var mockLogger = new Mock<IKestrelTrace>();
|
||||
mockLogger
|
||||
.Setup(logger => logger.RequestBodyDone("ConnectionId", "RequestId"))
|
||||
.Callback(() => logEvent.SetResult(null));
|
||||
.Callback(() => logEvent.SetResult());
|
||||
mockLogger
|
||||
.Setup(logger => logger.IsEnabled(Extensions.Logging.LogLevel.Debug))
|
||||
.Returns(true);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
|||
|
||||
private MemoryHandle _bufferHandle;
|
||||
private Task _processingTask;
|
||||
private readonly TaskCompletionSource<object> _waitForConnectionClosedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private readonly TaskCompletionSource _waitForConnectionClosedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private bool _connectionClosed;
|
||||
|
||||
public LibuvConnection(UvStreamHandle socket,
|
||||
|
|
@ -253,7 +253,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
|||
{
|
||||
state.CancelConnectionClosedToken();
|
||||
|
||||
state._waitForConnectionClosedTcs.TrySetResult(null);
|
||||
state._waitForConnectionClosedTcs.TrySetResult();
|
||||
},
|
||||
this,
|
||||
preferLocal: false);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
|||
private readonly LibuvFunctions _libuv;
|
||||
private readonly IHostApplicationLifetime _appLifetime;
|
||||
private readonly Thread _thread;
|
||||
private readonly TaskCompletionSource<object> _threadTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private readonly TaskCompletionSource _threadTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private readonly UvLoopHandle _loop;
|
||||
private readonly UvAsyncHandle _post;
|
||||
private Queue<Work> _workAdding = new Queue<Work>(1024);
|
||||
|
|
@ -224,7 +224,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
|||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var work = new Work
|
||||
{
|
||||
CallbackAdapter = CallbackAdapter<T>.PostAsyncCallbackAdapter,
|
||||
|
|
@ -344,7 +344,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
|||
_closeError = _closeError == null ? ex : new AggregateException(_closeError, ex);
|
||||
}
|
||||
WriteReqPool.Dispose();
|
||||
_threadTcs.SetResult(null);
|
||||
_threadTcs.SetResult();
|
||||
|
||||
#if DEBUG && !INNER_LOOP
|
||||
// Check for handle leaks after disposing everything
|
||||
|
|
@ -383,7 +383,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
|||
try
|
||||
{
|
||||
work.CallbackAdapter(work.Callback, work.State);
|
||||
work.Completion?.TrySetResult(null);
|
||||
work.Completion?.TrySetResult();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -446,7 +446,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
|||
public Action<object, object> CallbackAdapter;
|
||||
public object Callback;
|
||||
public object State;
|
||||
public TaskCompletionSource<object> Completion;
|
||||
public TaskCompletionSource Completion;
|
||||
}
|
||||
|
||||
private struct CloseHandle
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
|||
}
|
||||
|
||||
// Create a pipe connection and keep it open without sending any data
|
||||
var connectTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var connectTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var connectionTrace = new LibuvTrace(new TestApplicationErrorLogger());
|
||||
var pipe = new UvPipeHandle(connectionTrace);
|
||||
|
||||
|
|
@ -147,7 +147,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
|||
}
|
||||
else
|
||||
{
|
||||
connectTcs.SetResult(null);
|
||||
connectTcs.SetResult();
|
||||
}
|
||||
},
|
||||
null);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests.TestHelpers
|
|||
private uv_async_cb _onPost;
|
||||
|
||||
private readonly object _postLock = new object();
|
||||
private TaskCompletionSource<object> _onPostTcs = new TaskCompletionSource<object>();
|
||||
private TaskCompletionSource _onPostTcs = new TaskCompletionSource();
|
||||
private bool _completedOnPostTcs;
|
||||
|
||||
private bool _stopLoop;
|
||||
|
|
@ -41,7 +41,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests.TestHelpers
|
|||
{
|
||||
if (_completedOnPostTcs)
|
||||
{
|
||||
_onPostTcs = new TaskCompletionSource<object>();
|
||||
_onPostTcs = new TaskCompletionSource();
|
||||
_completedOnPostTcs = false;
|
||||
}
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests.TestHelpers
|
|||
// when the code attempts to call uv_async_send after awaiting
|
||||
// OnPostTask. Task.Run so the run loop doesn't block either.
|
||||
var onPostTcs = _onPostTcs;
|
||||
Task.Run(() => onPostTcs.TrySetResult(null));
|
||||
Task.Run(() => onPostTcs.TrySetResult());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Experimental.Quic.Intern
|
|||
private string _connectionId;
|
||||
private const int MinAllocBufferSize = 4096;
|
||||
private volatile Exception _shutdownReason;
|
||||
private readonly TaskCompletionSource<object> _waitForConnectionClosedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private readonly TaskCompletionSource _waitForConnectionClosedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private readonly object _shutdownLock = new object();
|
||||
|
||||
public QuicStreamContext(QuicStream stream, QuicConnectionContext connection, QuicTransportContext context)
|
||||
|
|
@ -200,7 +200,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Experimental.Quic.Intern
|
|||
{
|
||||
state.CancelConnectionClosedToken();
|
||||
|
||||
state._waitForConnectionClosedTcs.TrySetResult(null);
|
||||
state._waitForConnectionClosedTcs.TrySetResult();
|
||||
},
|
||||
this,
|
||||
preferLocal: false);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal
|
|||
private volatile bool _socketDisposed;
|
||||
private volatile Exception _shutdownReason;
|
||||
private Task _processingTask;
|
||||
private readonly TaskCompletionSource<object> _waitForConnectionClosedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private readonly TaskCompletionSource _waitForConnectionClosedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private bool _connectionClosed;
|
||||
private readonly bool _waitForData;
|
||||
|
||||
|
|
@ -317,7 +317,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal
|
|||
{
|
||||
state.CancelConnectionClosedToken();
|
||||
|
||||
state._waitForConnectionClosedTcs.TrySetResult(null);
|
||||
state._waitForConnectionClosedTcs.TrySetResult();
|
||||
},
|
||||
this,
|
||||
preferLocal: false);
|
||||
|
|
|
|||
|
|
@ -47,16 +47,16 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.Http2
|
|||
[SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/9985", Queues = "Fedora.28.Amd64;Fedora.28.Amd64.Open")]
|
||||
public async Task GracefulShutdownWaitsForRequestsToFinish()
|
||||
{
|
||||
var requestStarted = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestUnblocked = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestStopping = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestStarted = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestUnblocked = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestStopping = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var mockKestrelTrace = new Mock<KestrelTrace>(TestApplicationErrorLogger)
|
||||
{
|
||||
CallBase = true
|
||||
};
|
||||
mockKestrelTrace
|
||||
.Setup(m => m.Http2ConnectionClosing(It.IsAny<string>()))
|
||||
.Callback(() => requestStopping.SetResult(null));
|
||||
.Callback(() => requestStopping.SetResult());
|
||||
|
||||
var testContext = new TestServiceContext(LoggerFactory, mockKestrelTrace.Object);
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.Http2
|
|||
|
||||
using (var server = new TestServer(async context =>
|
||||
{
|
||||
requestStarted.SetResult(null);
|
||||
requestStarted.SetResult();
|
||||
await requestUnblocked.Task.DefaultTimeout();
|
||||
await context.Response.WriteAsync("hello world " + context.Request.Protocol);
|
||||
},
|
||||
|
|
@ -88,7 +88,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.Http2
|
|||
await requestStopping.Task.DefaultTimeout();
|
||||
|
||||
// Unblock the request
|
||||
requestUnblocked.SetResult(null);
|
||||
requestUnblocked.SetResult();
|
||||
|
||||
Assert.Equal("hello world HTTP/2", await requestTask);
|
||||
await stopTask.DefaultTimeout();
|
||||
|
|
@ -103,8 +103,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.Http2
|
|||
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/21521")] // Test still quarantined due to Sockets.Functional tests.
|
||||
public async Task GracefulTurnsAbortiveIfRequestsDoNotFinish()
|
||||
{
|
||||
var requestStarted = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestUnblocked = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestStarted = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestUnblocked = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
var memoryPoolFactory = new DiagnosticMemoryPoolFactory(allowLateReturn: true);
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.Http2
|
|||
// Abortive shutdown leaves one request hanging
|
||||
using (var server = new TestServer(async context =>
|
||||
{
|
||||
requestStarted.SetResult(null);
|
||||
requestStarted.SetResult();
|
||||
await requestUnblocked.Task.DefaultTimeout();
|
||||
await context.Response.WriteAsync("hello world " + context.Request.Protocol);
|
||||
},
|
||||
|
|
@ -154,7 +154,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.Http2
|
|||
Assert.Contains(TestApplicationErrorLogger.Messages, m => m.Message.Contains("Some connections failed to close gracefully during server shutdown."));
|
||||
Assert.DoesNotContain(TestApplicationErrorLogger.Messages, m => m.Message.Contains("Request finished in"));
|
||||
|
||||
requestUnblocked.SetResult(null);
|
||||
requestUnblocked.SetResult();
|
||||
|
||||
await memoryPoolFactory.WhenAllBlocksReturned(TestConstants.DefaultTimeout);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,8 +118,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
var bytesWrittenPollingInterval = TimeSpan.FromMilliseconds(bytesWrittenTimeout.TotalMilliseconds / 10);
|
||||
var maxSendSize = 4096;
|
||||
|
||||
var startReadingRequestBody = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var clientFinishedSendingRequestBody = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var startReadingRequestBody = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var clientFinishedSendingRequestBody = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var lastBytesWritten = DateTime.MaxValue;
|
||||
|
||||
var memoryPoolFactory = new DiagnosticMemoryPoolFactory(allowLateReturn: true);
|
||||
|
|
@ -145,7 +145,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
}
|
||||
|
||||
Assert.Equal(data.Length, bytesWritten);
|
||||
clientFinishedSendingRequestBody.TrySetResult(null);
|
||||
clientFinishedSendingRequestBody.TrySetResult();
|
||||
};
|
||||
|
||||
var sendTask = sendFunc();
|
||||
|
|
@ -180,7 +180,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
Assert.InRange(bytesWritten, minimumExpectedBytesWritten, maximumExpectedBytesWritten);
|
||||
|
||||
// Tell server to start reading request body
|
||||
startReadingRequestBody.TrySetResult(null);
|
||||
startReadingRequestBody.TrySetResult();
|
||||
|
||||
// Wait for sendTask to finish sending the remaining bytes
|
||||
await sendTask;
|
||||
|
|
@ -191,7 +191,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
await sendTask;
|
||||
|
||||
// Tell server to start reading request body
|
||||
startReadingRequestBody.TrySetResult(null);
|
||||
startReadingRequestBody.TrySetResult();
|
||||
}
|
||||
|
||||
await AssertStreamContains(stream, $"bytesRead: {data.Length}");
|
||||
|
|
@ -211,8 +211,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
var bytesWrittenPollingInterval = TimeSpan.FromMilliseconds(bytesWrittenTimeout.TotalMilliseconds / 10);
|
||||
var maxSendSize = 4096;
|
||||
|
||||
var startReadingRequestBody = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var clientFinishedSendingRequestBody = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var startReadingRequestBody = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var clientFinishedSendingRequestBody = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var lastBytesWritten = DateTime.MaxValue;
|
||||
|
||||
var memoryPoolFactory = new DiagnosticMemoryPoolFactory(allowLateReturn: true);
|
||||
|
|
@ -237,7 +237,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
lastBytesWritten = DateTime.Now;
|
||||
}
|
||||
|
||||
clientFinishedSendingRequestBody.TrySetResult(null);
|
||||
clientFinishedSendingRequestBody.TrySetResult();
|
||||
};
|
||||
|
||||
var ignore = sendFunc();
|
||||
|
|
@ -276,16 +276,16 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
}
|
||||
}
|
||||
// Allow appfunc to unblock
|
||||
startReadingRequestBody.SetResult(null);
|
||||
clientFinishedSendingRequestBody.SetResult(null);
|
||||
startReadingRequestBody.SetResult();
|
||||
clientFinishedSendingRequestBody.SetResult();
|
||||
await memoryPoolFactory.WhenAllBlocksReturned(TestConstants.DefaultTimeout);
|
||||
}
|
||||
|
||||
private async Task<IWebHost> StartWebHost(long? maxRequestBufferSize,
|
||||
byte[] expectedBody,
|
||||
bool useConnectionAdapter,
|
||||
TaskCompletionSource<object> startReadingRequestBody,
|
||||
TaskCompletionSource<object> clientFinishedSendingRequestBody,
|
||||
TaskCompletionSource startReadingRequestBody,
|
||||
TaskCompletionSource clientFinishedSendingRequestBody,
|
||||
Func<MemoryPool<byte>> memoryPoolFactory = null)
|
||||
{
|
||||
var host = TransportSelector.GetWebHostBuilder(memoryPoolFactory, maxRequestBufferSize)
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
public async Task CanHandleMultipleConcurrentRequests()
|
||||
{
|
||||
var requestNumber = 0;
|
||||
var ensureConcurrentRequestTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var ensureConcurrentRequestTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
using (var server = new TestServer(async context =>
|
||||
{
|
||||
|
|
@ -181,7 +181,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
}
|
||||
else
|
||||
{
|
||||
ensureConcurrentRequestTcs.SetResult(null);
|
||||
ensureConcurrentRequestTcs.SetResult();
|
||||
}
|
||||
}, new TestServiceContext(LoggerFactory)))
|
||||
{
|
||||
|
|
@ -504,15 +504,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
public async Task ConnectionClosedTokenFiresOnClientFIN(ListenOptions listenOptions)
|
||||
{
|
||||
var testContext = new TestServiceContext(LoggerFactory);
|
||||
var appStartedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var connectionClosedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var appStartedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var connectionClosedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
using (var server = new TestServer(context =>
|
||||
{
|
||||
appStartedTcs.SetResult(null);
|
||||
appStartedTcs.SetResult();
|
||||
|
||||
var connectionLifetimeFeature = context.Features.Get<IConnectionLifetimeFeature>();
|
||||
connectionLifetimeFeature.ConnectionClosed.Register(() => connectionClosedTcs.SetResult(null));
|
||||
connectionLifetimeFeature.ConnectionClosed.Register(() => connectionClosedTcs.SetResult());
|
||||
|
||||
return Task.CompletedTask;
|
||||
}, testContext, listenOptions))
|
||||
|
|
@ -540,12 +540,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
public async Task ConnectionClosedTokenFiresOnServerFIN(ListenOptions listenOptions)
|
||||
{
|
||||
var testContext = new TestServiceContext(LoggerFactory);
|
||||
var connectionClosedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var connectionClosedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
using (var server = new TestServer(context =>
|
||||
{
|
||||
var connectionLifetimeFeature = context.Features.Get<IConnectionLifetimeFeature>();
|
||||
connectionLifetimeFeature.ConnectionClosed.Register(() => connectionClosedTcs.SetResult(null));
|
||||
connectionLifetimeFeature.ConnectionClosed.Register(() => connectionClosedTcs.SetResult());
|
||||
|
||||
return Task.CompletedTask;
|
||||
}, testContext, listenOptions))
|
||||
|
|
@ -577,12 +577,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
public async Task ConnectionClosedTokenFiresOnServerAbort(ListenOptions listenOptions)
|
||||
{
|
||||
var testContext = new TestServiceContext(LoggerFactory);
|
||||
var connectionClosedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var connectionClosedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
using (var server = new TestServer(context =>
|
||||
{
|
||||
var connectionLifetimeFeature = context.Features.Get<IConnectionLifetimeFeature>();
|
||||
connectionLifetimeFeature.ConnectionClosed.Register(() => connectionClosedTcs.SetResult(null));
|
||||
connectionLifetimeFeature.ConnectionClosed.Register(() => connectionClosedTcs.SetResult());
|
||||
|
||||
context.Abort();
|
||||
|
||||
|
|
@ -623,7 +623,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
|
||||
var testContext = new TestServiceContext(LoggerFactory);
|
||||
|
||||
var readTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var readTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var registrationTcs = new TaskCompletionSource<int>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestId = 0;
|
||||
|
||||
|
|
@ -713,10 +713,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
const int connectionFinSentEventId = 7;
|
||||
const int maxRequestBufferSize = 4096;
|
||||
|
||||
var readCallbackUnwired = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var clientClosedConnection = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var serverClosedConnection = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var appFuncCompleted = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var readCallbackUnwired = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var clientClosedConnection = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var serverClosedConnection = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var appFuncCompleted = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
TestSink.MessageLogged += context =>
|
||||
{
|
||||
|
|
@ -728,11 +728,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
|
||||
if (context.EventId.Id == connectionPausedEventId)
|
||||
{
|
||||
readCallbackUnwired.TrySetResult(null);
|
||||
readCallbackUnwired.TrySetResult();
|
||||
}
|
||||
else if (context.EventId == connectionFinSentEventId)
|
||||
{
|
||||
serverClosedConnection.SetResult(null);
|
||||
serverClosedConnection.SetResult();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -760,7 +760,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
|
||||
await serverClosedConnection.Task;
|
||||
|
||||
appFuncCompleted.SetResult(null);
|
||||
appFuncCompleted.SetResult();
|
||||
}, testContext, listenOptions))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
|
|
@ -778,7 +778,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
await readCallbackUnwired.Task.DefaultTimeout();
|
||||
}
|
||||
|
||||
clientClosedConnection.SetResult(null);
|
||||
clientClosedConnection.SetResult();
|
||||
|
||||
await appFuncCompleted.Task.DefaultTimeout();
|
||||
await server.StopAsync();
|
||||
|
|
@ -791,8 +791,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
[MemberData(nameof(ConnectionMiddlewareData))]
|
||||
public async Task AppCanHandleClientAbortingConnectionMidRequest(ListenOptions listenOptions)
|
||||
{
|
||||
var readTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var appStartedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var readTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var appStartedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
var mockKestrelTrace = new Mock<IKestrelTrace>();
|
||||
var testContext = new TestServiceContext(LoggerFactory, mockKestrelTrace.Object);
|
||||
|
|
@ -801,7 +801,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
|
||||
using (var server = new TestServer(async context =>
|
||||
{
|
||||
appStartedTcs.SetResult(null);
|
||||
appStartedTcs.SetResult();
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -139,19 +139,19 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
[MemberData(nameof(ConnectionMiddlewareData))]
|
||||
public async Task WriteAfterConnectionCloseNoops(ListenOptions listenOptions)
|
||||
{
|
||||
var connectionClosed = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestStarted = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var appCompleted = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var connectionClosed = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestStarted = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var appCompleted = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
using (var server = new TestServer(async httpContext =>
|
||||
{
|
||||
try
|
||||
{
|
||||
requestStarted.SetResult(null);
|
||||
requestStarted.SetResult();
|
||||
await connectionClosed.Task.DefaultTimeout();
|
||||
httpContext.Response.ContentLength = 12;
|
||||
await httpContext.Response.WriteAsync("hello, world");
|
||||
appCompleted.TrySetResult(null);
|
||||
appCompleted.TrySetResult();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -172,7 +172,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
await connection.WaitForConnectionClose();
|
||||
}
|
||||
|
||||
connectionClosed.SetResult(null);
|
||||
connectionClosed.SetResult();
|
||||
|
||||
await appCompleted.Task.DefaultTimeout();
|
||||
await server.StopAsync();
|
||||
|
|
@ -189,19 +189,19 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
// Ensure string is long enough to disable write-behind buffering
|
||||
var largeString = new string('a', maxBytesPreCompleted + 1);
|
||||
|
||||
var writeTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestAbortedWh = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestStartWh = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var writeTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestAbortedWh = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestStartWh = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
using (var server = new TestServer(async httpContext =>
|
||||
{
|
||||
requestStartWh.SetResult(null);
|
||||
requestStartWh.SetResult();
|
||||
|
||||
var response = httpContext.Response;
|
||||
var request = httpContext.Request;
|
||||
var lifetime = httpContext.Features.Get<IHttpRequestLifetimeFeature>();
|
||||
|
||||
lifetime.RequestAborted.Register(() => requestAbortedWh.SetResult(null));
|
||||
lifetime.RequestAborted.Register(() => requestAbortedWh.SetResult());
|
||||
await requestAbortedWh.Task.DefaultTimeout();
|
||||
|
||||
try
|
||||
|
|
@ -250,10 +250,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
const int connectionPausedEventId = 4;
|
||||
const int maxRequestBufferSize = 4096;
|
||||
|
||||
var requestAborted = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var readCallbackUnwired = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var clientClosedConnection = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var writeTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestAborted = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var readCallbackUnwired = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var clientClosedConnection = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var writeTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
TestSink.MessageLogged += context =>
|
||||
{
|
||||
|
|
@ -265,7 +265,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
|
||||
if (context.EventId.Id == connectionPausedEventId)
|
||||
{
|
||||
readCallbackUnwired.TrySetResult(null);
|
||||
readCallbackUnwired.TrySetResult();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -288,7 +288,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
|
||||
using (var server = new TestServer(async context =>
|
||||
{
|
||||
context.RequestAborted.Register(() => requestAborted.SetResult(null));
|
||||
context.RequestAborted.Register(() => requestAborted.SetResult());
|
||||
|
||||
await clientClosedConnection.Task;
|
||||
|
||||
|
|
@ -328,7 +328,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
await readCallbackUnwired.Task.DefaultTimeout();
|
||||
}
|
||||
|
||||
clientClosedConnection.SetResult(null);
|
||||
clientClosedConnection.SetResult();
|
||||
|
||||
await Assert.ThrowsAnyAsync<OperationCanceledException>(() => writeTcs.Task).DefaultTimeout();
|
||||
await server.StopAsync();
|
||||
|
|
@ -349,14 +349,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
const int responseBodySegmentSize = 65536;
|
||||
const int responseBodySegmentCount = 100;
|
||||
|
||||
var requestAborted = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var appCompletedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestAborted = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var appCompletedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
var scratchBuffer = new byte[responseBodySegmentSize];
|
||||
|
||||
using (var server = new TestServer(async context =>
|
||||
{
|
||||
context.RequestAborted.Register(() => requestAborted.SetResult(null));
|
||||
context.RequestAborted.Register(() => requestAborted.SetResult());
|
||||
|
||||
for (var i = 0; i < responseBodySegmentCount; i++)
|
||||
{
|
||||
|
|
@ -365,7 +365,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
}
|
||||
|
||||
await requestAborted.Task.DefaultTimeout();
|
||||
appCompletedTcs.SetResult(null);
|
||||
appCompletedTcs.SetResult();
|
||||
}, new TestServiceContext(LoggerFactory), listenOptions))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
|
|
@ -459,18 +459,18 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
var responseSize = chunks * chunkSize;
|
||||
var chunkData = new byte[chunkSize];
|
||||
|
||||
var responseRateTimeoutMessageLogged = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var connectionStopMessageLogged = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestAborted = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var appFuncCompleted = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var responseRateTimeoutMessageLogged = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var connectionStopMessageLogged = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestAborted = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var appFuncCompleted = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
var mockKestrelTrace = new Mock<IKestrelTrace>();
|
||||
mockKestrelTrace
|
||||
.Setup(trace => trace.ResponseMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>()))
|
||||
.Callback(() => responseRateTimeoutMessageLogged.SetResult(null));
|
||||
.Callback(() => responseRateTimeoutMessageLogged.SetResult());
|
||||
mockKestrelTrace
|
||||
.Setup(trace => trace.ConnectionStop(It.IsAny<string>()))
|
||||
.Callback(() => connectionStopMessageLogged.SetResult(null));
|
||||
.Callback(() => connectionStopMessageLogged.SetResult());
|
||||
|
||||
var testContext = new TestServiceContext(LoggerFactory, mockKestrelTrace.Object)
|
||||
{
|
||||
|
|
@ -489,7 +489,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
async Task App(HttpContext context)
|
||||
{
|
||||
appLogger.LogInformation("Request received");
|
||||
context.RequestAborted.Register(() => requestAborted.SetResult(null));
|
||||
context.RequestAborted.Register(() => requestAborted.SetResult());
|
||||
|
||||
context.Response.ContentLength = responseSize;
|
||||
|
||||
|
|
@ -507,7 +507,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
appFuncCompleted.SetResult(null);
|
||||
appFuncCompleted.SetResult();
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -559,18 +559,18 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
|
||||
var certificate = TestResources.GetTestCertificate();
|
||||
|
||||
var responseRateTimeoutMessageLogged = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var connectionStopMessageLogged = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var aborted = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var appFuncCompleted = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var responseRateTimeoutMessageLogged = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var connectionStopMessageLogged = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var aborted = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var appFuncCompleted = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
var mockKestrelTrace = new Mock<IKestrelTrace>();
|
||||
mockKestrelTrace
|
||||
.Setup(trace => trace.ResponseMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>()))
|
||||
.Callback(() => responseRateTimeoutMessageLogged.SetResult(null));
|
||||
.Callback(() => responseRateTimeoutMessageLogged.SetResult());
|
||||
mockKestrelTrace
|
||||
.Setup(trace => trace.ConnectionStop(It.IsAny<string>()))
|
||||
.Callback(() => connectionStopMessageLogged.SetResult(null));
|
||||
.Callback(() => connectionStopMessageLogged.SetResult());
|
||||
|
||||
var testContext = new TestServiceContext(LoggerFactory, mockKestrelTrace.Object)
|
||||
{
|
||||
|
|
@ -594,7 +594,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
{
|
||||
context.RequestAborted.Register(() =>
|
||||
{
|
||||
aborted.SetResult(null);
|
||||
aborted.SetResult();
|
||||
});
|
||||
|
||||
context.Response.ContentLength = chunks * chunkSize;
|
||||
|
|
@ -608,7 +608,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
appFuncCompleted.SetResult(null);
|
||||
appFuncCompleted.SetResult();
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
|
|
@ -646,18 +646,18 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
var responseSize = bufferCount * bufferSize;
|
||||
var buffer = new byte[bufferSize];
|
||||
|
||||
var responseRateTimeoutMessageLogged = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var connectionStopMessageLogged = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestAborted = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var copyToAsyncCts = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var responseRateTimeoutMessageLogged = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var connectionStopMessageLogged = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestAborted = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var copyToAsyncCts = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
var mockKestrelTrace = new Mock<IKestrelTrace>();
|
||||
mockKestrelTrace
|
||||
.Setup(trace => trace.ResponseMinimumDataRateNotSatisfied(It.IsAny<string>(), It.IsAny<string>()))
|
||||
.Callback(() => responseRateTimeoutMessageLogged.SetResult(null));
|
||||
.Callback(() => responseRateTimeoutMessageLogged.SetResult());
|
||||
mockKestrelTrace
|
||||
.Setup(trace => trace.ConnectionStop(It.IsAny<string>()))
|
||||
.Callback(() => connectionStopMessageLogged.SetResult(null));
|
||||
.Callback(() => connectionStopMessageLogged.SetResult());
|
||||
|
||||
var testContext = new TestServiceContext(LoggerFactory, mockKestrelTrace.Object)
|
||||
{
|
||||
|
|
@ -679,7 +679,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
{
|
||||
context.RequestAborted.Register(() =>
|
||||
{
|
||||
requestAborted.SetResult(null);
|
||||
requestAborted.SetResult();
|
||||
});
|
||||
|
||||
try
|
||||
|
|
@ -740,7 +740,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
var chunkData = new byte[chunkSize];
|
||||
|
||||
var requestAborted = false;
|
||||
var appFuncCompleted = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var appFuncCompleted = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var mockKestrelTrace = new Mock<IKestrelTrace>();
|
||||
|
||||
var testContext = new TestServiceContext(LoggerFactory, mockKestrelTrace.Object)
|
||||
|
|
@ -773,7 +773,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
await context.Response.BodyWriter.WriteAsync(new Memory<byte>(chunkData, 0, chunkData.Length), context.RequestAborted);
|
||||
}
|
||||
|
||||
appFuncCompleted.SetResult(null);
|
||||
appFuncCompleted.SetResult();
|
||||
}
|
||||
|
||||
using (var server = new TestServer(App, testContext, listenOptions))
|
||||
|
|
@ -906,7 +906,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
var chunkData = new byte[chunkSize];
|
||||
|
||||
var requestAborted = false;
|
||||
var appFuncCompleted = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var appFuncCompleted = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var mockKestrelTrace = new Mock<IKestrelTrace>();
|
||||
|
||||
var testContext = new TestServiceContext(LoggerFactory, mockKestrelTrace.Object)
|
||||
|
|
@ -939,7 +939,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
await context.Response.BodyWriter.WriteAsync(new Memory<byte>(chunkData, 0, chunkData.Length), context.RequestAborted);
|
||||
}
|
||||
|
||||
appFuncCompleted.SetResult(null);
|
||||
appFuncCompleted.SetResult();
|
||||
}
|
||||
|
||||
using (var server = new TestServer(App, testContext, listenOptions))
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
|
||||
try
|
||||
{
|
||||
var serverConnectionCompletedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var serverConnectionCompletedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
async Task EchoServer(ConnectionContext connection)
|
||||
{
|
||||
|
|
@ -68,7 +68,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
}
|
||||
finally
|
||||
{
|
||||
serverConnectionCompletedTcs.TrySetResult(null);
|
||||
serverConnectionCompletedTcs.TrySetResult();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -842,7 +842,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
public async Task ClosingConnectionMidChunkPrefixThrows()
|
||||
{
|
||||
var testContext = new TestServiceContext(LoggerFactory);
|
||||
var readStartedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var readStartedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
var exTcs = new TaskCompletionSource<BadHttpRequestException>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
|
@ -850,7 +850,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
await using (var server = new TestServer(async httpContext =>
|
||||
{
|
||||
var readTask = httpContext.Request.Body.CopyToAsync(Stream.Null);
|
||||
readStartedTcs.SetResult(null);
|
||||
readStartedTcs.SetResult();
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -892,7 +892,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
[Fact]
|
||||
public async Task ChunkedRequestCallCancelPendingReadWorks()
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var tcs = new TaskCompletionSource();
|
||||
var testContext = new TestServiceContext(LoggerFactory);
|
||||
|
||||
await using (var server = new TestServer(async httpContext =>
|
||||
|
|
@ -911,7 +911,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
|
||||
Assert.True((await requestTask).IsCanceled);
|
||||
|
||||
tcs.SetResult(null);
|
||||
tcs.SetResult();
|
||||
|
||||
response.Headers["Content-Length"] = new[] { "11" };
|
||||
|
||||
|
|
@ -1063,7 +1063,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
[Fact]
|
||||
public async Task ChunkedRequestCallCompleteWithExceptionCauses500()
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var testContext = new TestServiceContext(LoggerFactory);
|
||||
|
||||
using (var server = new TestServer(async httpContext =>
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
$"Date: {testContext.DateHeaderValue}",
|
||||
"Transfer-Encoding: chunked",
|
||||
"",
|
||||
length.ToString("x"),
|
||||
length.ToString("x"),
|
||||
new string('a', length),
|
||||
"0",
|
||||
"",
|
||||
|
|
@ -485,7 +485,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
{
|
||||
var testContext = new TestServiceContext(LoggerFactory);
|
||||
|
||||
var flushWh = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var flushWh = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
await using (var server = new TestServer(async httpContext =>
|
||||
{
|
||||
|
|
@ -514,7 +514,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
"Hello ",
|
||||
"");
|
||||
|
||||
flushWh.SetResult(null);
|
||||
flushWh.SetResult();
|
||||
|
||||
await connection.Receive(
|
||||
"6",
|
||||
|
|
|
|||
|
|
@ -23,12 +23,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
[Fact]
|
||||
public async Task ResetsCountWhenConnectionClosed()
|
||||
{
|
||||
var requestTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var releasedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var releasedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var lockedTcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var counter = new EventRaisingResourceCounter(ResourceCounter.Quota(1));
|
||||
counter.OnLock += (s, e) => lockedTcs.TrySetResult(e);
|
||||
counter.OnRelease += (s, e) => releasedTcs.TrySetResult(null);
|
||||
counter.OnRelease += (s, e) => releasedTcs.TrySetResult();
|
||||
|
||||
await using (var server = CreateServerWithMaxConnections(async context =>
|
||||
{
|
||||
|
|
@ -41,7 +41,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
await connection.SendEmptyGetAsKeepAlive(); ;
|
||||
await connection.Receive("HTTP/1.1 200 OK");
|
||||
Assert.True(await lockedTcs.Task.DefaultTimeout());
|
||||
requestTcs.TrySetResult(null);
|
||||
requestTcs.TrySetResult();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
public async Task RejectsConnectionsWhenLimitReached()
|
||||
{
|
||||
const int max = 10;
|
||||
var requestTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
await using (var server = CreateServerWithMaxConnections(async context =>
|
||||
{
|
||||
|
|
@ -136,7 +136,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
}
|
||||
}
|
||||
|
||||
requestTcs.TrySetResult(null);
|
||||
requestTcs.TrySetResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -147,8 +147,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
const int count = 100;
|
||||
var opened = 0;
|
||||
var closed = 0;
|
||||
var openedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var closedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var openedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var closedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
var counter = new EventRaisingResourceCounter(ResourceCounter.Quota(uint.MaxValue));
|
||||
|
||||
|
|
@ -156,7 +156,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
{
|
||||
if (e && Interlocked.Increment(ref opened) >= count)
|
||||
{
|
||||
openedTcs.TrySetResult(null);
|
||||
openedTcs.TrySetResult();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -164,7 +164,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
{
|
||||
if (Interlocked.Increment(ref closed) >= count)
|
||||
{
|
||||
closedTcs.TrySetResult(null);
|
||||
closedTcs.TrySetResult();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
[Fact]
|
||||
public async Task ImmediateShutdownDuringOnConnectionAsyncDoesNotCrash()
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var listenOptions = new ListenOptions(new IPEndPoint(IPAddress.Loopback, 0));
|
||||
listenOptions.Use(next =>
|
||||
{
|
||||
|
|
@ -182,7 +182,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
{
|
||||
stopTask = server.StopAsync();
|
||||
|
||||
tcs.TrySetResult(null);
|
||||
tcs.TrySetResult();
|
||||
}
|
||||
|
||||
await stopTask;
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
[Fact]
|
||||
public async Task StreamPool_SingleStream_ReturnedToPool()
|
||||
{
|
||||
var serverTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var serverTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
await InitializeConnectionAsync(async context =>
|
||||
{
|
||||
|
|
@ -223,7 +223,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
await StartStreamAsync(1, _browserRequestHeaders, endStream: true);
|
||||
|
||||
var stream = _connection._streams[1];
|
||||
serverTcs.SetResult(null);
|
||||
serverTcs.SetResult();
|
||||
|
||||
await ExpectAsync(Http2FrameType.HEADERS,
|
||||
withLength: 36,
|
||||
|
|
@ -303,7 +303,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
[QuarantinedTest]
|
||||
public async Task StreamPool_MultipleStreamsInSequence_PooledStreamReused()
|
||||
{
|
||||
TaskCompletionSource<object> appDelegateTcs = null;
|
||||
TaskCompletionSource appDelegateTcs = null;
|
||||
|
||||
await InitializeConnectionAsync(async context =>
|
||||
{
|
||||
|
|
@ -312,13 +312,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
|
||||
Assert.Equal(0, _connection.StreamPool.Count);
|
||||
|
||||
appDelegateTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
appDelegateTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
await StartStreamAsync(1, _browserRequestHeaders, endStream: true);
|
||||
|
||||
// Get the in progress stream
|
||||
var stream = _connection._streams[1];
|
||||
|
||||
appDelegateTcs.TrySetResult(null);
|
||||
appDelegateTcs.TrySetResult();
|
||||
|
||||
await ExpectAsync(Http2FrameType.HEADERS,
|
||||
withLength: 36,
|
||||
|
|
@ -330,13 +330,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
Assert.True(_connection.StreamPool.TryPeek(out var pooledStream));
|
||||
Assert.Equal(stream, pooledStream);
|
||||
|
||||
appDelegateTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
appDelegateTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
await StartStreamAsync(3, _browserRequestHeaders, endStream: true);
|
||||
|
||||
// New stream has been taken from the pool
|
||||
Assert.Equal(0, _connection.StreamPool.Count);
|
||||
|
||||
appDelegateTcs.TrySetResult(null);
|
||||
appDelegateTcs.TrySetResult();
|
||||
|
||||
await ExpectAsync(Http2FrameType.HEADERS,
|
||||
withLength: 6,
|
||||
|
|
@ -368,7 +368,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
[QuarantinedTest]
|
||||
public async Task StreamPool_StreamIsInvalidState_DontReturnedToPool()
|
||||
{
|
||||
var serverTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var serverTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
await InitializeConnectionAsync(async context =>
|
||||
{
|
||||
|
|
@ -381,7 +381,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
await StartStreamAsync(1, _browserRequestHeaders, endStream: true);
|
||||
|
||||
var stream = _connection._streams[1];
|
||||
serverTcs.SetResult(null);
|
||||
serverTcs.SetResult();
|
||||
|
||||
await ExpectAsync(Http2FrameType.HEADERS,
|
||||
withLength: 32,
|
||||
|
|
@ -933,10 +933,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
[Fact]
|
||||
public async Task DATA_Received_Multiplexed_AppMustNotBlockOtherFrames()
|
||||
{
|
||||
var stream1Read = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var stream1ReadFinished = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var stream3Read = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var stream3ReadFinished = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var stream1Read = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var stream1ReadFinished = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var stream3Read = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var stream3ReadFinished = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
await InitializeConnectionAsync(async context =>
|
||||
{
|
||||
|
|
@ -944,13 +944,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
var read = await context.Request.Body.ReadAsync(new byte[10], 0, 10);
|
||||
if (context.Features.Get<IHttp2StreamIdFeature>().StreamId == 1)
|
||||
{
|
||||
stream1Read.TrySetResult(null);
|
||||
stream1Read.TrySetResult();
|
||||
|
||||
await stream1ReadFinished.Task.DefaultTimeout();
|
||||
}
|
||||
else
|
||||
{
|
||||
stream3Read.TrySetResult(null);
|
||||
stream3Read.TrySetResult();
|
||||
|
||||
await stream3ReadFinished.Task.DefaultTimeout();
|
||||
}
|
||||
|
|
@ -966,7 +966,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
await SendDataAsync(3, _helloBytes, endStream: true);
|
||||
await stream3Read.Task.DefaultTimeout();
|
||||
|
||||
stream3ReadFinished.TrySetResult(null);
|
||||
stream3ReadFinished.TrySetResult();
|
||||
|
||||
await ExpectAsync(Http2FrameType.HEADERS,
|
||||
withLength: 32,
|
||||
|
|
@ -981,7 +981,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
withFlags: (byte)Http2DataFrameFlags.END_STREAM,
|
||||
withStreamId: 3);
|
||||
|
||||
stream1ReadFinished.TrySetResult(null);
|
||||
stream1ReadFinished.TrySetResult();
|
||||
|
||||
await ExpectAsync(Http2FrameType.HEADERS,
|
||||
withLength: 2,
|
||||
|
|
@ -1380,15 +1380,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
public async Task Frame_MultipleStreams_CanBeCreatedIfClientCountIsLessThanActualMaxStreamCount()
|
||||
{
|
||||
_serviceContext.ServerOptions.Limits.Http2.MaxStreamsPerConnection = 1;
|
||||
var firstRequestBlock = new TaskCompletionSource<object>();
|
||||
var firstRequestReceived = new TaskCompletionSource<object>();
|
||||
var firstRequestBlock = new TaskCompletionSource();
|
||||
var firstRequestReceived = new TaskCompletionSource();
|
||||
var makeFirstRequestWait = false;
|
||||
await InitializeConnectionAsync(async context =>
|
||||
{
|
||||
if (!makeFirstRequestWait)
|
||||
{
|
||||
makeFirstRequestWait = true;
|
||||
firstRequestReceived.SetResult(null);
|
||||
firstRequestReceived.SetResult();
|
||||
await firstRequestBlock.Task.DefaultTimeout();
|
||||
}
|
||||
});
|
||||
|
|
@ -1405,7 +1405,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
withFlags: (byte)(Http2HeadersFrameFlags.END_HEADERS | Http2HeadersFrameFlags.END_STREAM),
|
||||
withStreamId: 3);
|
||||
|
||||
firstRequestBlock.SetResult(null);
|
||||
firstRequestBlock.SetResult();
|
||||
|
||||
await StopConnectionAsync(3, ignoreNonGoAwayFrames: false);
|
||||
}
|
||||
|
|
@ -1414,7 +1414,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
public async Task Frame_MultipleStreams_RequestsNotFinished_EnhanceYourCalm()
|
||||
{
|
||||
_serviceContext.ServerOptions.Limits.Http2.MaxStreamsPerConnection = 1;
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
await InitializeConnectionAsync(async context =>
|
||||
{
|
||||
await tcs.Task.DefaultTimeout();
|
||||
|
|
@ -1431,7 +1431,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
expectedErrorCode: Http2ErrorCode.ENHANCE_YOUR_CALM,
|
||||
expectedErrorMessage: CoreStrings.Http2TellClientToCalmDown);
|
||||
|
||||
tcs.SetResult(null);
|
||||
tcs.SetResult();
|
||||
|
||||
await StopConnectionAsync(5, ignoreNonGoAwayFrames: false);
|
||||
}
|
||||
|
|
@ -1542,7 +1542,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
}
|
||||
}
|
||||
|
||||
_runningStreams[streamId].SetResult(null);
|
||||
_runningStreams[streamId].SetResult();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -1772,22 +1772,22 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
[Fact]
|
||||
public async Task HEADERS_Received_AppCannotBlockOtherFrames()
|
||||
{
|
||||
var firstRequestReceived = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var finishFirstRequest = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var secondRequestReceived = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var finishSecondRequest = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var firstRequestReceived = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var finishFirstRequest = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var secondRequestReceived = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var finishSecondRequest = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
await InitializeConnectionAsync(async context =>
|
||||
{
|
||||
if (!firstRequestReceived.Task.IsCompleted)
|
||||
{
|
||||
firstRequestReceived.TrySetResult(null);
|
||||
firstRequestReceived.TrySetResult();
|
||||
|
||||
await finishFirstRequest.Task.DefaultTimeout();
|
||||
}
|
||||
else
|
||||
{
|
||||
secondRequestReceived.TrySetResult(null);
|
||||
secondRequestReceived.TrySetResult();
|
||||
|
||||
await finishSecondRequest.Task.DefaultTimeout();
|
||||
}
|
||||
|
|
@ -1801,14 +1801,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
|
||||
await secondRequestReceived.Task.DefaultTimeout();
|
||||
|
||||
finishSecondRequest.TrySetResult(null);
|
||||
finishSecondRequest.TrySetResult();
|
||||
|
||||
await ExpectAsync(Http2FrameType.HEADERS,
|
||||
withLength: 36,
|
||||
withFlags: (byte)(Http2HeadersFrameFlags.END_HEADERS | Http2HeadersFrameFlags.END_STREAM),
|
||||
withStreamId: 3);
|
||||
|
||||
finishFirstRequest.TrySetResult(null);
|
||||
finishFirstRequest.TrySetResult();
|
||||
|
||||
await ExpectAsync(Http2FrameType.HEADERS,
|
||||
withLength: 6,
|
||||
|
|
@ -1971,7 +1971,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
|
||||
_connection.ServerSettings.MaxConcurrentStreams = 1;
|
||||
|
||||
var requestBlocker = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestBlocker = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
await InitializeConnectionAsync(context => requestBlocker.Task);
|
||||
|
||||
await StartStreamAsync(1, _browserRequestHeaders, endStream: true);
|
||||
|
|
@ -1980,7 +1980,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
|
||||
await WaitForStreamErrorAsync(3, Http2ErrorCode.REFUSED_STREAM, CoreStrings.Http2ErrorMaxStreams);
|
||||
|
||||
requestBlocker.SetResult(0);
|
||||
requestBlocker.SetResult();
|
||||
|
||||
await ExpectAsync(Http2FrameType.HEADERS,
|
||||
withLength: 36,
|
||||
|
|
@ -2533,15 +2533,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
{
|
||||
var streamId = context.Features.Get<IHttp2StreamIdFeature>().StreamId;
|
||||
|
||||
var abortedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var writeTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var abortedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var writeTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
context.RequestAborted.Register(() =>
|
||||
{
|
||||
lock (_abortedStreamIdsLock)
|
||||
{
|
||||
_abortedStreamIds.Add(streamId);
|
||||
abortedTcs.SetResult(null);
|
||||
abortedTcs.SetResult();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -2559,11 +2559,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
|
||||
await context.Response.Body.WriteAsync(_maxData, 0, remainingBytesBeforeBackpressure + 1);
|
||||
|
||||
writeTcs.SetResult(null);
|
||||
writeTcs.SetResult();
|
||||
|
||||
await abortedTcs.Task;
|
||||
|
||||
_runningStreams[streamId].SetResult(null);
|
||||
_runningStreams[streamId].SetResult();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -2651,15 +2651,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
{
|
||||
var streamId = context.Features.Get<IHttp2StreamIdFeature>().StreamId;
|
||||
|
||||
var abortedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var writeTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var abortedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var writeTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
context.RequestAborted.Register(() =>
|
||||
{
|
||||
lock (_abortedStreamIdsLock)
|
||||
{
|
||||
_abortedStreamIds.Add(streamId);
|
||||
abortedTcs.SetResult(null);
|
||||
abortedTcs.SetResult();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -2667,11 +2667,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
{
|
||||
writeTasks[streamId] = writeTcs.Task;
|
||||
await context.Response.Body.WriteAsync(_helloWorldBytes, 0, _helloWorldBytes.Length);
|
||||
writeTcs.SetResult(null);
|
||||
writeTcs.SetResult();
|
||||
|
||||
await abortedTcs.Task;
|
||||
|
||||
_runningStreams[streamId].SetResult(null);
|
||||
_runningStreams[streamId].SetResult();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -3481,15 +3481,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
{
|
||||
var streamId = context.Features.Get<IHttp2StreamIdFeature>().StreamId;
|
||||
|
||||
var abortedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var writeTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var abortedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var writeTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
context.RequestAborted.Register(() =>
|
||||
{
|
||||
lock (_abortedStreamIdsLock)
|
||||
{
|
||||
_abortedStreamIds.Add(streamId);
|
||||
abortedTcs.SetResult(null);
|
||||
abortedTcs.SetResult();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -3507,11 +3507,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
|
||||
await context.Response.Body.WriteAsync(_maxData, 0, remainingBytesBeforeBackpressure + 1);
|
||||
|
||||
writeTcs.SetResult(null);
|
||||
writeTcs.SetResult();
|
||||
|
||||
await abortedTcs.Task;
|
||||
|
||||
_runningStreams[streamId].SetResult(null);
|
||||
_runningStreams[streamId].SetResult();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -3583,15 +3583,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
{
|
||||
var streamId = context.Features.Get<IHttp2StreamIdFeature>().StreamId;
|
||||
|
||||
var abortedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var writeTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var abortedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var writeTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
context.RequestAborted.Register(() =>
|
||||
{
|
||||
lock (_abortedStreamIdsLock)
|
||||
{
|
||||
_abortedStreamIds.Add(streamId);
|
||||
abortedTcs.SetResult(null);
|
||||
abortedTcs.SetResult();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -3599,11 +3599,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
{
|
||||
writeTasks[streamId] = writeTcs.Task;
|
||||
await context.Response.Body.WriteAsync(_helloWorldBytes, 0, _helloWorldBytes.Length);
|
||||
writeTcs.SetResult(null);
|
||||
writeTcs.SetResult();
|
||||
|
||||
await abortedTcs.Task;
|
||||
|
||||
_runningStreams[streamId].SetResult(null);
|
||||
_runningStreams[streamId].SetResult();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -3811,8 +3811,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
// This way we're sure that if Response.Body.WriteAsync returns an incomplete task, it's because
|
||||
// of the flow control window and not Pipe backpressure.
|
||||
var expectingDataSem = new SemaphoreSlim(0);
|
||||
var backpressureObservedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var backpressureReleasedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var backpressureObservedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var backpressureReleasedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
// Double the stream window to be 128KiB so it doesn't interfere with the rest of the test.
|
||||
_clientSettings.InitialWindowSize = Http2PeerSettings.DefaultInitialWindowSize * 2;
|
||||
|
|
@ -3834,10 +3834,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
var lastWriteTask = context.Response.Body.WriteAsync(_maxData, 0, _maxData.Length);
|
||||
|
||||
Assert.False(lastWriteTask.IsCompleted);
|
||||
backpressureObservedTcs.TrySetResult(null);
|
||||
backpressureObservedTcs.TrySetResult();
|
||||
|
||||
await lastWriteTask;
|
||||
backpressureReleasedTcs.TrySetResult(null);
|
||||
backpressureReleasedTcs.TrySetResult();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -4325,7 +4325,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
withStreamId: 1);
|
||||
|
||||
// Send a blocked request
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
task = tcs.Task;
|
||||
await StartStreamAsync(3, _browserRequestHeaders, endStream: false);
|
||||
|
||||
|
|
@ -4344,7 +4344,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
Assert.False(result.IsCompleted);
|
||||
|
||||
// Unblock the request and ProcessRequestsAsync
|
||||
tcs.TrySetResult(null);
|
||||
tcs.TrySetResult();
|
||||
await _connectionTask;
|
||||
|
||||
// Assert connection's Input pipe is completed
|
||||
|
|
|
|||
|
|
@ -715,7 +715,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
[Fact]
|
||||
public async Task ContentLength_Received_MultipleDataFrame_ReadViaPipeAndStream_Verified()
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var tcs = new TaskCompletionSource();
|
||||
var headers = new[]
|
||||
{
|
||||
new KeyValuePair<string, string>(HeaderNames.Method, "POST"),
|
||||
|
|
@ -729,7 +729,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
Assert.Equal(1, readResult.Buffer.Length);
|
||||
context.Request.BodyReader.AdvanceTo(readResult.Buffer.End);
|
||||
|
||||
tcs.SetResult(null);
|
||||
tcs.SetResult();
|
||||
|
||||
var buffer = new byte[100];
|
||||
|
||||
|
|
@ -1256,7 +1256,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
[Fact]
|
||||
public async Task StartAsync_WithoutFinalFlushDoesNotFlushUntilResponseEnd()
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
var headers = new[]
|
||||
{
|
||||
|
|
@ -1285,7 +1285,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
withFlags: (byte)Http2DataFrameFlags.NONE,
|
||||
withStreamId: 1);
|
||||
|
||||
tcs.SetResult(null);
|
||||
tcs.SetResult();
|
||||
|
||||
await ExpectAsync(Http2FrameType.DATA,
|
||||
withLength: 0,
|
||||
|
|
@ -2335,7 +2335,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
|
||||
await context.Response.Body.WriteAsync(new byte[10], 0, 10);
|
||||
|
||||
_runningStreams[streamIdFeature.StreamId].TrySetResult(null);
|
||||
_runningStreams[streamIdFeature.StreamId].TrySetResult();
|
||||
});
|
||||
|
||||
await StartStreamAsync(1, _browserRequestHeaders, endStream: true);
|
||||
|
|
@ -2370,7 +2370,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
context.Response.BodyWriter.Advance(10);
|
||||
await context.Response.BodyWriter.FlushAsync();
|
||||
|
||||
_runningStreams[streamIdFeature.StreamId].TrySetResult(null);
|
||||
_runningStreams[streamIdFeature.StreamId].TrySetResult();
|
||||
});
|
||||
|
||||
await StartStreamAsync(1, _browserRequestHeaders, endStream: true);
|
||||
|
|
@ -2406,7 +2406,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
_abortedStreamIds.Add(streamIdFeature.StreamId);
|
||||
}
|
||||
|
||||
_runningStreams[streamIdFeature.StreamId].TrySetResult(null);
|
||||
_runningStreams[streamIdFeature.StreamId].TrySetResult();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -2449,7 +2449,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
_abortedStreamIds.Add(streamIdFeature.StreamId);
|
||||
}
|
||||
|
||||
_runningStreams[streamIdFeature.StreamId].TrySetResult(null);
|
||||
_runningStreams[streamIdFeature.StreamId].TrySetResult();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -2483,7 +2483,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
_abortedStreamIds.Add(streamIdFeature.StreamId);
|
||||
}
|
||||
|
||||
_runningStreams[streamIdFeature.StreamId].TrySetResult(null);
|
||||
_runningStreams[streamIdFeature.StreamId].TrySetResult();
|
||||
});
|
||||
|
||||
context.Abort();
|
||||
|
|
@ -2523,7 +2523,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
_abortedStreamIds.Add(streamIdFeature.StreamId);
|
||||
}
|
||||
|
||||
_runningStreams[streamIdFeature.StreamId].TrySetResult(null);
|
||||
_runningStreams[streamIdFeature.StreamId].TrySetResult();
|
||||
});
|
||||
|
||||
await context.Response.Body.WriteAsync(new byte[10], 0, 10);
|
||||
|
|
@ -3926,7 +3926,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
[Fact]
|
||||
public async Task CompleteAsync_AdvanceAfterComplete_AdvanceThrows()
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var tcs = new TaskCompletionSource();
|
||||
var headers = new[]
|
||||
{
|
||||
new KeyValuePair<string, string>(HeaderNames.Method, "GET"),
|
||||
|
|
@ -3943,7 +3943,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
tcs.SetResult(null);
|
||||
tcs.SetResult();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -130,14 +130,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
internal readonly Mock<ITimeoutHandler> _mockTimeoutHandler = new Mock<ITimeoutHandler>();
|
||||
internal readonly Mock<MockTimeoutControlBase> _mockTimeoutControl;
|
||||
|
||||
protected readonly ConcurrentDictionary<int, TaskCompletionSource<object>> _runningStreams = new ConcurrentDictionary<int, TaskCompletionSource<object>>();
|
||||
protected readonly ConcurrentDictionary<int, TaskCompletionSource> _runningStreams = new ConcurrentDictionary<int, TaskCompletionSource>();
|
||||
protected readonly Dictionary<string, string> _receivedHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
protected readonly Dictionary<string, string> _receivedTrailers = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
protected readonly Dictionary<string, string> _decodedHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
protected readonly HashSet<int> _abortedStreamIds = new HashSet<int>();
|
||||
protected readonly object _abortedStreamIdsLock = new object();
|
||||
protected readonly TaskCompletionSource<object> _closingStateReached = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
protected readonly TaskCompletionSource<object> _closedStateReached = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
protected readonly TaskCompletionSource _closingStateReached = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
protected readonly TaskCompletionSource _closedStateReached = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
protected readonly RequestDelegate _noopApplication;
|
||||
protected readonly RequestDelegate _readHeadersApplication;
|
||||
|
|
@ -174,10 +174,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
|
||||
_mockKestrelTrace
|
||||
.Setup(m => m.Http2ConnectionClosing(It.IsAny<string>()))
|
||||
.Callback(() => _closingStateReached.SetResult(null));
|
||||
.Callback(() => _closingStateReached.SetResult());
|
||||
_mockKestrelTrace
|
||||
.Setup(m => m.Http2ConnectionClosed(It.IsAny<string>(), It.IsAny<int>()))
|
||||
.Callback(() => _closedStateReached.SetResult(null));
|
||||
.Callback(() => _closedStateReached.SetResult());
|
||||
|
||||
_mockConnectionContext.Setup(c => c.Abort(It.IsAny<ConnectionAbortedException>())).Callback<ConnectionAbortedException>(ex =>
|
||||
{
|
||||
|
|
@ -300,7 +300,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
|
||||
await sem.WaitAsync().DefaultTimeout();
|
||||
|
||||
_runningStreams[streamIdFeature.StreamId].TrySetResult(null);
|
||||
_runningStreams[streamIdFeature.StreamId].TrySetResult();
|
||||
};
|
||||
|
||||
_waitForAbortFlushingApplication = async context =>
|
||||
|
|
@ -322,7 +322,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
|
||||
await context.Response.Body.FlushAsync();
|
||||
|
||||
_runningStreams[streamIdFeature.StreamId].TrySetResult(null);
|
||||
_runningStreams[streamIdFeature.StreamId].TrySetResult();
|
||||
};
|
||||
|
||||
_readRateApplication = async context =>
|
||||
|
|
@ -509,7 +509,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
protected Task StartStreamAsync(int streamId, IEnumerable<KeyValuePair<string, string>> headers, bool endStream)
|
||||
{
|
||||
var writableBuffer = _pair.Application.Output;
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
_runningStreams[streamId] = tcs;
|
||||
|
||||
writableBuffer.WriteStartStream(streamId, _hpackEncoder, GetHeadersEnumerator(headers), _headerEncodingBuffer, endStream);
|
||||
|
|
@ -519,7 +519,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
protected Task StartStreamAsync(int streamId, Span<byte> headerData, bool endStream)
|
||||
{
|
||||
var writableBuffer = _pair.Application.Output;
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
_runningStreams[streamId] = tcs;
|
||||
|
||||
writableBuffer.WriteStartStream(streamId, headerData, endStream);
|
||||
|
|
@ -538,7 +538,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
protected Task SendHeadersWithPaddingAsync(int streamId, IEnumerable<KeyValuePair<string, string>> headers, byte padLength, bool endStream)
|
||||
{
|
||||
var writableBuffer = _pair.Application.Output;
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
_runningStreams[streamId] = tcs;
|
||||
|
||||
var frame = new Http2Frame();
|
||||
|
|
@ -580,7 +580,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
protected Task SendHeadersWithPriorityAsync(int streamId, IEnumerable<KeyValuePair<string, string>> headers, byte priority, int streamDependency, bool endStream)
|
||||
{
|
||||
var writableBuffer = _pair.Application.Output;
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
_runningStreams[streamId] = tcs;
|
||||
|
||||
var frame = new Http2Frame();
|
||||
|
|
@ -625,7 +625,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
protected Task SendHeadersWithPaddingAndPriorityAsync(int streamId, IEnumerable<KeyValuePair<string, string>> headers, byte padLength, byte priority, int streamDependency, bool endStream)
|
||||
{
|
||||
var writableBuffer = _pair.Application.Output;
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
_runningStreams[streamId] = tcs;
|
||||
|
||||
var frame = new Http2Frame();
|
||||
|
|
|
|||
|
|
@ -87,11 +87,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
|
||||
// The KeepAlive timeout is set when the stream completes processing on a background thread, so we need to hook the
|
||||
// keep-alive set afterwards to make a reliable test.
|
||||
var setTimeoutTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var setTimeoutTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
_mockTimeoutControl.Setup(c => c.SetTimeout(It.IsAny<long>(), TimeoutReason.KeepAlive)).Callback<long, TimeoutReason>((t, r) =>
|
||||
{
|
||||
_timeoutControl.SetTimeout(t, r);
|
||||
setTimeoutTcs.SetResult(null);
|
||||
setTimeoutTcs.SetResult();
|
||||
});
|
||||
|
||||
// Send continuation frame to verify intermediate request header timeout doesn't interfere with keep-alive timeout.
|
||||
|
|
@ -851,7 +851,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
var initialConnectionWindowSize = _serviceContext.ServerOptions.Limits.Http2.InitialConnectionWindowSize;
|
||||
var framesConnectionInWindow = initialConnectionWindowSize / Http2PeerSettings.DefaultMaxFrameSize;
|
||||
|
||||
var backpressureTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var backpressureTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
var mockSystemClock = _serviceContext.MockSystemClock;
|
||||
var limits = _serviceContext.ServerOptions.Limits;
|
||||
|
|
@ -900,7 +900,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
_mockTimeoutHandler.Verify(h => h.OnTimeout(It.IsAny<TimeoutReason>()), Times.Never);
|
||||
|
||||
// Opening the connection window starts the read rate timeout enforcement after that point.
|
||||
backpressureTcs.SetResult(null);
|
||||
backpressureTcs.SetResult();
|
||||
|
||||
await ExpectAsync(Http2FrameType.HEADERS,
|
||||
withLength: 6,
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
await using (var server = new TestServer(context =>
|
||||
{
|
||||
appStartedWh.Release();
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
return tcs.Task;
|
||||
},
|
||||
testContext))
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
[QuarantinedTest]
|
||||
public async Task DoesNotThrowObjectDisposedExceptionFromWriteAsyncAfterConnectionIsAborted()
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var loggerProvider = new HandshakeErrorLoggerProvider();
|
||||
LoggerFactory.AddProvider(loggerProvider);
|
||||
|
||||
|
|
@ -231,7 +231,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
try
|
||||
{
|
||||
await httpContext.Response.WriteAsync($"hello, world");
|
||||
tcs.SetResult(null);
|
||||
tcs.SetResult();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -317,7 +317,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
var testContext = new TestServiceContext(LoggerFactory);
|
||||
var heartbeatManager = new HeartbeatManager(testContext.ConnectionManager);
|
||||
|
||||
var handshakeStartedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var handshakeStartedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
TimeSpan handshakeTimeout = default;
|
||||
|
||||
await using (var server = new TestServer(context => Task.CompletedTask,
|
||||
|
|
@ -329,7 +329,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
o.ServerCertificate = new X509Certificate2(TestResources.GetTestCertificate());
|
||||
o.OnAuthenticate = (_, __) =>
|
||||
{
|
||||
handshakeStartedTcs.SetResult(null);
|
||||
handshakeStartedTcs.SetResult();
|
||||
};
|
||||
|
||||
handshakeTimeout = o.HandshakeTimeout;
|
||||
|
|
@ -488,13 +488,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
{
|
||||
public LogLevel LastLogLevel { get; set; }
|
||||
public EventId LastEventId { get; set; }
|
||||
public TaskCompletionSource<object> LogTcs { get; } = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
public TaskCompletionSource LogTcs { get; } = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
|
||||
{
|
||||
LastLogLevel = logLevel;
|
||||
LastEventId = eventId;
|
||||
LogTcs.SetResult(null);
|
||||
LogTcs.SetResult();
|
||||
}
|
||||
|
||||
public bool IsEnabled(LogLevel logLevel)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
private static readonly TimeSpan _longDelay = TimeSpan.FromSeconds(30);
|
||||
private static readonly TimeSpan _shortDelay = TimeSpan.FromSeconds(_longDelay.TotalSeconds / 10);
|
||||
|
||||
private readonly TaskCompletionSource<object> _firstRequestReceived = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private readonly TaskCompletionSource _firstRequestReceived = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
[Fact]
|
||||
public async Task ConnectionClosedWhenKeepAliveTimeoutExpires()
|
||||
|
|
@ -240,7 +240,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
var responseStream = httpContext.Response.Body;
|
||||
var responseBytes = Encoding.ASCII.GetBytes("hello, world");
|
||||
|
||||
_firstRequestReceived.TrySetResult(null);
|
||||
_firstRequestReceived.TrySetResult();
|
||||
|
||||
if (httpContext.Request.Path == "/longrunning")
|
||||
{
|
||||
|
|
@ -285,8 +285,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
token.Register(() => tcs.SetResult(null));
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
token.Register(() => tcs.SetResult());
|
||||
return tcs.Task;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
var serviceContext = new TestServiceContext(LoggerFactory);
|
||||
var heartbeatManager = new HeartbeatManager(serviceContext.ConnectionManager);
|
||||
|
||||
var appRunningEvent = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var appRunningEvent = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
await using (var server = new TestServer(context =>
|
||||
{
|
||||
|
|
@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
// return context.Request.Body.ReadAsync(new byte[1], 0, 1);
|
||||
|
||||
var readTask = context.Request.Body.ReadAsync(new byte[1], 0, 1);
|
||||
appRunningEvent.SetResult(null);
|
||||
appRunningEvent.SetResult();
|
||||
return readTask;
|
||||
}, serviceContext))
|
||||
{
|
||||
|
|
@ -104,13 +104,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
date.OnHeartbeat(clock.UtcNow);
|
||||
serviceContext.DateHeaderValueManager = date;
|
||||
|
||||
var appRunningEvent = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var appRunningEvent = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
await using (var server = new TestServer(context =>
|
||||
{
|
||||
context.Features.Get<IHttpMinRequestBodyDataRateFeature>().MinDataRate = null;
|
||||
|
||||
appRunningEvent.SetResult(null);
|
||||
appRunningEvent.SetResult();
|
||||
return Task.CompletedTask;
|
||||
}, serviceContext))
|
||||
{
|
||||
|
|
@ -146,8 +146,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
var serviceContext = new TestServiceContext(LoggerFactory);
|
||||
var heartbeatManager = new HeartbeatManager(serviceContext.ConnectionManager);
|
||||
|
||||
var appRunningTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var exceptionSwallowedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var appRunningTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var exceptionSwallowedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
await using (var server = new TestServer(async context =>
|
||||
{
|
||||
|
|
@ -157,7 +157,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
// See comment in RequestTimesOutWhenRequestBodyNotReceivedAtSpecifiedMinimumRate for
|
||||
// why we call ReadAsync before setting the appRunningEvent.
|
||||
var readTask = context.Request.Body.ReadAsync(new byte[1], 0, 1);
|
||||
appRunningTcs.SetResult(null);
|
||||
appRunningTcs.SetResult();
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -165,7 +165,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
}
|
||||
catch (Microsoft.AspNetCore.Http.BadHttpRequestException ex) when (ex.StatusCode == 408)
|
||||
{
|
||||
exceptionSwallowedTcs.SetResult(null);
|
||||
exceptionSwallowedTcs.SetResult();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -84,8 +84,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
[Fact]
|
||||
public async Task RequestBodyReadAsyncCanBeCancelled()
|
||||
{
|
||||
var helloTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var readTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var helloTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var readTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var cts = new CancellationTokenSource();
|
||||
|
||||
await using (var server = new TestServer(async context =>
|
||||
|
|
@ -97,7 +97,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
|
||||
Assert.Equal("Hello ", Encoding.ASCII.GetString(buffer, 0, 6));
|
||||
|
||||
helloTcs.TrySetResult(null);
|
||||
helloTcs.TrySetResult();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -108,7 +108,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
try
|
||||
{
|
||||
var task = context.Request.Body.ReadAsync(buffer, 0, buffer.Length, cts.Token);
|
||||
readTcs.TrySetResult(null);
|
||||
readTcs.TrySetResult();
|
||||
await task;
|
||||
|
||||
context.Response.ContentLength = 12;
|
||||
|
|
@ -1052,19 +1052,19 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
public async Task ContentLengthReadAsyncSingleBytesAtATime()
|
||||
{
|
||||
var testContext = new TestServiceContext(LoggerFactory);
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var tcs2 = new TaskCompletionSource<object>();
|
||||
var tcs = new TaskCompletionSource();
|
||||
var tcs2 = new TaskCompletionSource();
|
||||
await using (var server = new TestServer(async httpContext =>
|
||||
{
|
||||
var readResult = await httpContext.Request.BodyReader.ReadAsync();
|
||||
Assert.Equal(3, readResult.Buffer.Length);
|
||||
tcs.SetResult(null);
|
||||
tcs.SetResult();
|
||||
|
||||
httpContext.Request.BodyReader.AdvanceTo(readResult.Buffer.Start, readResult.Buffer.End);
|
||||
|
||||
readResult = await httpContext.Request.BodyReader.ReadAsync();
|
||||
httpContext.Request.BodyReader.AdvanceTo(readResult.Buffer.Start, readResult.Buffer.End);
|
||||
tcs2.SetResult(null);
|
||||
tcs2.SetResult();
|
||||
|
||||
readResult = await httpContext.Request.BodyReader.ReadAsync();
|
||||
Assert.Equal(5, readResult.Buffer.Length);
|
||||
|
|
@ -1494,8 +1494,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
[Fact]
|
||||
public async Task DoesNotEnforceRequestBodyMinimumDataRateOnUpgradedRequest()
|
||||
{
|
||||
var appEvent = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var delayEvent = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var appEvent = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var delayEvent = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var serviceContext = new TestServiceContext(LoggerFactory);
|
||||
var heartbeatManager = new HeartbeatManager(serviceContext.ConnectionManager);
|
||||
|
||||
|
|
@ -1506,7 +1506,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
|
||||
using (var stream = await context.Features.Get<IHttpUpgradeFeature>().UpgradeAsync())
|
||||
{
|
||||
appEvent.SetResult(null);
|
||||
appEvent.SetResult();
|
||||
|
||||
// Read once to go through one set of TryPauseTimingReads()/TryResumeTimingReads() calls
|
||||
await stream.ReadAsync(new byte[1], 0, 1);
|
||||
|
|
@ -1536,7 +1536,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
serviceContext.MockSystemClock.UtcNow += TimeSpan.FromSeconds(5);
|
||||
heartbeatManager.OnHeartbeat(serviceContext.SystemClock.UtcNow);
|
||||
|
||||
delayEvent.SetResult(null);
|
||||
delayEvent.SetResult();
|
||||
|
||||
await connection.Send("b");
|
||||
|
||||
|
|
@ -1766,7 +1766,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
[Fact]
|
||||
public async Task ContentLengthRequestCallCancelPendingReadWorks()
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var tcs = new TaskCompletionSource();
|
||||
var testContext = new TestServiceContext(LoggerFactory);
|
||||
|
||||
await using (var server = new TestServer(async httpContext =>
|
||||
|
|
@ -1785,7 +1785,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
|
||||
Assert.True((await requestTask).IsCanceled);
|
||||
|
||||
tcs.SetResult(null);
|
||||
tcs.SetResult();
|
||||
|
||||
response.Headers["Content-Length"] = new[] { "11" };
|
||||
|
||||
|
|
@ -1863,7 +1863,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
{
|
||||
var testContext = new TestServiceContext(LoggerFactory);
|
||||
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var tcs = new TaskCompletionSource();
|
||||
await using (var server = new TestServer(async httpContext =>
|
||||
{
|
||||
var request = httpContext.Request;
|
||||
|
|
@ -1873,7 +1873,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
|
||||
httpContext.Request.BodyReader.Complete();
|
||||
|
||||
tcs.SetResult(null);
|
||||
tcs.SetResult();
|
||||
|
||||
}, testContext))
|
||||
{
|
||||
|
|
@ -1902,7 +1902,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
[Fact]
|
||||
public async Task ContentLengthCallCompleteWithExceptionCauses500()
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var testContext = new TestServiceContext(LoggerFactory);
|
||||
|
||||
await using (var server = new TestServer(async httpContext =>
|
||||
|
|
|
|||
|
|
@ -39,12 +39,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
{
|
||||
var transportConnection = connection.TransportConnection;
|
||||
|
||||
var outputBufferedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var outputBufferedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
#pragma warning disable 0618 // TODO: Repalce OnWriterCompleted
|
||||
transportConnection.Output.OnWriterCompleted((ex, state) =>
|
||||
{
|
||||
((TaskCompletionSource<object>)state).SetResult(null);
|
||||
((TaskCompletionSource)state).SetResult();
|
||||
},
|
||||
outputBufferedTcs);
|
||||
#pragma warning restore
|
||||
|
|
|
|||
|
|
@ -34,14 +34,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
public async Task OnCompleteCalledEvenWhenOnStartingNotCalled()
|
||||
{
|
||||
var onStartingCalled = false;
|
||||
TaskCompletionSource<object> onCompletedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
TaskCompletionSource onCompletedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
await using (var server = new TestServer(context =>
|
||||
{
|
||||
context.Response.OnStarting(() => Task.Run(() => onStartingCalled = true));
|
||||
context.Response.OnCompleted(() => Task.Run(() =>
|
||||
{
|
||||
onCompletedTcs.SetResult(null);
|
||||
onCompletedTcs.SetResult();
|
||||
}));
|
||||
|
||||
// Prevent OnStarting call (see HttpProtocol.ProcessRequestsAsync()).
|
||||
|
|
@ -141,8 +141,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
{
|
||||
var serviceContext = new TestServiceContext(LoggerFactory);
|
||||
var cts = new CancellationTokenSource();
|
||||
var appTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var writeBlockedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var appTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var writeBlockedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
await using (var server = new TestServer(async context =>
|
||||
{
|
||||
|
|
@ -164,7 +164,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
completedTask = await Task.WhenAny(writeTask, timerTask);
|
||||
}
|
||||
|
||||
writeBlockedTcs.TrySetResult(null);
|
||||
writeBlockedTcs.TrySetResult();
|
||||
|
||||
await writeTask;
|
||||
}
|
||||
|
|
@ -175,7 +175,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
}
|
||||
finally
|
||||
{
|
||||
appTcs.TrySetResult(null);
|
||||
appTcs.TrySetResult();
|
||||
}
|
||||
}, serviceContext))
|
||||
{
|
||||
|
|
@ -331,7 +331,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
[Fact]
|
||||
public async Task OnCompletedShouldNotBlockAResponse()
|
||||
{
|
||||
var delayTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var delayTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
await using (var server = new TestServer(async context =>
|
||||
{
|
||||
|
|
@ -361,20 +361,20 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
"");
|
||||
}
|
||||
|
||||
delayTcs.SetResult(null);
|
||||
delayTcs.SetResult();
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task InvalidChunkedEncodingInRequestShouldNotBlockOnCompleted()
|
||||
{
|
||||
var onCompletedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var onCompletedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
await using (var server = new TestServer(httpContext =>
|
||||
{
|
||||
httpContext.Response.OnCompleted(() => Task.Run(() =>
|
||||
{
|
||||
onCompletedTcs.SetResult(null);
|
||||
onCompletedTcs.SetResult();
|
||||
}));
|
||||
return Task.CompletedTask;
|
||||
}, new TestServiceContext(LoggerFactory)))
|
||||
|
|
@ -644,11 +644,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
{
|
||||
const string response = "hello, world";
|
||||
|
||||
var logTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var logTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var mockKestrelTrace = new Mock<IKestrelTrace>();
|
||||
mockKestrelTrace
|
||||
.Setup(trace => trace.ConnectionHeadResponseBodyWrite(It.IsAny<string>(), response.Length))
|
||||
.Callback<string, long>((connectionId, count) => logTcs.SetResult(null));
|
||||
.Callback<string, long>((connectionId, count) => logTcs.SetResult());
|
||||
|
||||
await using (var server = new TestServer(async httpContext =>
|
||||
{
|
||||
|
|
@ -831,13 +831,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
[Fact]
|
||||
public async Task WhenAppWritesLessThanContentLengthErrorLogged()
|
||||
{
|
||||
var logTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var logTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var mockTrace = new Mock<IKestrelTrace>();
|
||||
mockTrace
|
||||
.Setup(trace => trace.ApplicationError(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<InvalidOperationException>()))
|
||||
.Callback<string, string, Exception>((connectionId, requestId, ex) =>
|
||||
{
|
||||
logTcs.SetResult(null);
|
||||
logTcs.SetResult();
|
||||
});
|
||||
|
||||
await using (var server = new TestServer(async httpContext =>
|
||||
|
|
@ -886,13 +886,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
{
|
||||
InvalidOperationException completeEx = null;
|
||||
|
||||
var logTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var logTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var mockTrace = new Mock<IKestrelTrace>();
|
||||
mockTrace
|
||||
.Setup(trace => trace.ApplicationError(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<InvalidOperationException>()))
|
||||
.Callback<string, string, Exception>((connectionId, requestId, ex) =>
|
||||
{
|
||||
logTcs.SetResult(null);
|
||||
logTcs.SetResult();
|
||||
});
|
||||
|
||||
await using (var server = new TestServer(async httpContext =>
|
||||
|
|
@ -944,14 +944,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
[Fact]
|
||||
public async Task WhenAppWritesLessThanContentLengthButRequestIsAbortedErrorNotLogged()
|
||||
{
|
||||
var requestAborted = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var requestAborted = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var mockTrace = new Mock<IKestrelTrace>();
|
||||
|
||||
await using (var server = new TestServer(async httpContext =>
|
||||
{
|
||||
httpContext.RequestAborted.Register(() =>
|
||||
{
|
||||
requestAborted.SetResult(null);
|
||||
requestAborted.SetResult();
|
||||
});
|
||||
|
||||
httpContext.Response.ContentLength = 12;
|
||||
|
|
@ -1165,7 +1165,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
[Fact]
|
||||
public async Task HeadResponseBodyNotWrittenWithAsyncWrite()
|
||||
{
|
||||
var flushed = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var flushed = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
await using (var server = new TestServer(async httpContext =>
|
||||
{
|
||||
|
|
@ -1188,7 +1188,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
"",
|
||||
"");
|
||||
|
||||
flushed.SetResult(null);
|
||||
flushed.SetResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1196,7 +1196,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
[Fact]
|
||||
public async Task HeadResponseBodyNotWrittenWithSyncWrite()
|
||||
{
|
||||
var flushed = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var flushed = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
var serviceContext = new TestServiceContext(LoggerFactory) { ServerOptions = { AllowSynchronousIO = true } };
|
||||
|
||||
|
|
@ -1221,7 +1221,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
"",
|
||||
"");
|
||||
|
||||
flushed.SetResult(null);
|
||||
flushed.SetResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1229,7 +1229,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
[Fact]
|
||||
public async Task ZeroLengthWritesFlushHeaders()
|
||||
{
|
||||
var flushed = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var flushed = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
await using (var server = new TestServer(async httpContext =>
|
||||
{
|
||||
|
|
@ -1253,7 +1253,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
"",
|
||||
"");
|
||||
|
||||
flushed.SetResult(null);
|
||||
flushed.SetResult();
|
||||
|
||||
await connection.Receive("hello, world");
|
||||
}
|
||||
|
|
@ -1264,7 +1264,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
public async Task AppCanWriteOwnBadRequestResponse()
|
||||
{
|
||||
var expectedResponse = string.Empty;
|
||||
var responseWritten = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var responseWritten = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
await using (var server = new TestServer(async httpContext =>
|
||||
{
|
||||
|
|
@ -1278,7 +1278,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
httpContext.Response.StatusCode = StatusCodes.Status400BadRequest;
|
||||
httpContext.Response.ContentLength = ex.Message.Length;
|
||||
await httpContext.Response.WriteAsync(ex.Message);
|
||||
responseWritten.SetResult(null);
|
||||
responseWritten.SetResult();
|
||||
}
|
||||
}, new TestServiceContext(LoggerFactory)))
|
||||
{
|
||||
|
|
@ -2257,7 +2257,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
public async Task OnStartingThrowsInsideOnStartingCallbacksRuns()
|
||||
{
|
||||
var testContext = new TestServiceContext(LoggerFactory);
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
await using (var server = new TestServer(async httpContext =>
|
||||
{
|
||||
|
|
@ -2266,7 +2266,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
{
|
||||
response.OnStarting(state2 =>
|
||||
{
|
||||
tcs.TrySetResult(null);
|
||||
tcs.TrySetResult();
|
||||
return Task.CompletedTask;
|
||||
},
|
||||
null);
|
||||
|
|
@ -2301,7 +2301,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
public async Task OnCompletedThrowsInsideOnCompletedCallbackRuns()
|
||||
{
|
||||
var testContext = new TestServiceContext(LoggerFactory);
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
await using (var server = new TestServer(async httpContext =>
|
||||
{
|
||||
|
|
@ -2310,7 +2310,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
{
|
||||
response.OnCompleted(state2 =>
|
||||
{
|
||||
tcs.TrySetResult(null);
|
||||
tcs.TrySetResult();
|
||||
|
||||
return Task.CompletedTask;
|
||||
},
|
||||
|
|
@ -2565,8 +2565,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
feature.Abort();
|
||||
|
||||
// Ensure the response doesn't get flush before the abort is observed.
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
feature.ConnectionClosed.Register(() => tcs.TrySetResult(null));
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
feature.ConnectionClosed.Register(() => tcs.TrySetResult());
|
||||
|
||||
return tcs.Task;
|
||||
}, testContext))
|
||||
|
|
@ -2846,7 +2846,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
{
|
||||
var testContext = new TestServiceContext(LoggerFactory);
|
||||
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
await using (var server = new TestServer(async httpContext =>
|
||||
{
|
||||
|
|
@ -2874,7 +2874,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
"",
|
||||
"");
|
||||
// If we reach this point before the app exits, this means the flush finished early.
|
||||
tcs.SetResult(null);
|
||||
tcs.SetResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3027,14 +3027,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
var testContext = new TestServiceContext(LoggerFactory);
|
||||
|
||||
var callOrder = new Stack<int>();
|
||||
var onStartingTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var onStartingTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
await using (var server = new TestServer(async context =>
|
||||
{
|
||||
context.Response.OnStarting(_ =>
|
||||
{
|
||||
callOrder.Push(1);
|
||||
onStartingTcs.SetResult(null);
|
||||
onStartingTcs.SetResult();
|
||||
return Task.CompletedTask;
|
||||
}, null);
|
||||
context.Response.OnStarting(_ =>
|
||||
|
|
@ -3078,14 +3078,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
var testContext = new TestServiceContext(LoggerFactory);
|
||||
|
||||
var callOrder = new Stack<int>();
|
||||
var onCompletedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var onCompletedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
await using (var server = new TestServer(async context =>
|
||||
{
|
||||
context.Response.OnCompleted(_ =>
|
||||
{
|
||||
callOrder.Push(1);
|
||||
onCompletedTcs.SetResult(null);
|
||||
onCompletedTcs.SetResult();
|
||||
return Task.CompletedTask;
|
||||
}, null);
|
||||
context.Response.OnCompleted(_ =>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests.TestTrans
|
|||
|
||||
private readonly ILogger _logger;
|
||||
private bool _isClosed;
|
||||
private readonly TaskCompletionSource<object> _waitForCloseTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private readonly TaskCompletionSource _waitForCloseTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
public InMemoryTransportConnection(MemoryPool<byte> memoryPool, ILogger logger, PipeScheduler scheduler = null)
|
||||
{
|
||||
|
|
@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests.TestTrans
|
|||
{
|
||||
state._connectionClosedTokenSource.Cancel();
|
||||
|
||||
state._waitForCloseTcs.TrySetResult(null);
|
||||
state._waitForCloseTcs.TrySetResult();
|
||||
},
|
||||
this,
|
||||
preferLocal: false);
|
||||
|
|
@ -115,7 +115,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests.TestTrans
|
|||
private class ObservablePipeReader : PipeReader
|
||||
{
|
||||
private readonly PipeReader _reader;
|
||||
private readonly TaskCompletionSource<object> _tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private readonly TaskCompletionSource _tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
public Task WaitForReadTask => _tcs.Task;
|
||||
|
||||
|
|
@ -164,9 +164,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests.TestTrans
|
|||
private class ObservableValueTask<T> : IValueTaskSource<T>
|
||||
{
|
||||
private readonly ValueTask<T> _task;
|
||||
private readonly TaskCompletionSource<object> _tcs;
|
||||
private readonly TaskCompletionSource _tcs;
|
||||
|
||||
public ObservableValueTask(ValueTask<T> task, TaskCompletionSource<object> tcs)
|
||||
public ObservableValueTask(ValueTask<T> task, TaskCompletionSource tcs)
|
||||
{
|
||||
_task = task;
|
||||
_tcs = tcs;
|
||||
|
|
@ -198,7 +198,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests.TestTrans
|
|||
{
|
||||
_task.GetAwaiter().UnsafeOnCompleted(() => continuation(state));
|
||||
|
||||
_tcs.TrySetResult(null);
|
||||
_tcs.TrySetResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
[Fact]
|
||||
public async Task UpgradeCannotBeCalledMultipleTimes()
|
||||
{
|
||||
var upgradeTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var upgradeTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
await using (var server = new TestServer(async context =>
|
||||
{
|
||||
var feature = context.Features.Get<IHttpUpgradeFeature>();
|
||||
|
|
@ -260,7 +260,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
public async Task RejectsUpgradeWhenLimitReached()
|
||||
{
|
||||
const int limit = 10;
|
||||
var upgradeTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var upgradeTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var serviceContext = new TestServiceContext(LoggerFactory);
|
||||
serviceContext.ConnectionManager = new ConnectionManager(serviceContext.Log, ResourceCounter.Quota(limit));
|
||||
|
||||
|
|
@ -310,7 +310,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
[Fact]
|
||||
public async Task DoesNotThrowOnFin()
|
||||
{
|
||||
var appCompletedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var appCompletedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
await using (var server = new TestServer(async context =>
|
||||
{
|
||||
|
|
@ -320,7 +320,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
|||
try
|
||||
{
|
||||
await duplexStream.CopyToAsync(Stream.Null);
|
||||
appCompletedTcs.SetResult(null);
|
||||
appCompletedTcs.SetResult();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace System.Buffers
|
|||
|
||||
private readonly List<Exception> _blockAccessExceptions;
|
||||
|
||||
private readonly TaskCompletionSource<object> _allBlocksReturned;
|
||||
private readonly TaskCompletionSource _allBlocksReturned;
|
||||
|
||||
private int _totalBlocks;
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ namespace System.Buffers
|
|||
_rentTracking = rentTracking;
|
||||
_blocks = new HashSet<DiagnosticPoolBlock>();
|
||||
_syncObj = new object();
|
||||
_allBlocksReturned = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
_allBlocksReturned = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
_blockAccessExceptions = new List<Exception>();
|
||||
}
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ namespace System.Buffers
|
|||
}
|
||||
else
|
||||
{
|
||||
_allBlocksReturned.SetResult(null);
|
||||
_allBlocksReturned.SetResult();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -229,7 +229,6 @@ namespace Microsoft.AspNetCore.Http2Cat
|
|||
public Task StartStreamAsync(int streamId, IEnumerable<KeyValuePair<string, string>> headers, bool endStream)
|
||||
{
|
||||
var writableBuffer = _pair.Application.Output;
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
var frame = new Http2Frame();
|
||||
frame.PrepareHeaders(Http2HeadersFrameFlags.NONE, streamId);
|
||||
|
|
@ -328,7 +327,6 @@ namespace Microsoft.AspNetCore.Http2Cat
|
|||
public Task SendHeadersWithPaddingAsync(int streamId, IEnumerable<KeyValuePair<string, string>> headers, byte padLength, bool endStream)
|
||||
{
|
||||
var writableBuffer = _pair.Application.Output;
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
var frame = new Http2Frame();
|
||||
|
||||
|
|
@ -369,7 +367,6 @@ namespace Microsoft.AspNetCore.Http2Cat
|
|||
public Task SendHeadersWithPriorityAsync(int streamId, IEnumerable<KeyValuePair<string, string>> headers, byte priority, int streamDependency, bool endStream)
|
||||
{
|
||||
var writableBuffer = _pair.Application.Output;
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
var frame = new Http2Frame();
|
||||
frame.PrepareHeaders(Http2HeadersFrameFlags.END_HEADERS | Http2HeadersFrameFlags.PRIORITY, streamId);
|
||||
|
|
@ -413,7 +410,6 @@ namespace Microsoft.AspNetCore.Http2Cat
|
|||
public Task SendHeadersWithPaddingAndPriorityAsync(int streamId, IEnumerable<KeyValuePair<string, string>> headers, byte padLength, byte priority, int streamDependency, bool endStream)
|
||||
{
|
||||
var writableBuffer = _pair.Application.Output;
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
var frame = new Http2Frame();
|
||||
frame.PrepareHeaders(Http2HeadersFrameFlags.END_HEADERS | Http2HeadersFrameFlags.PADDED | Http2HeadersFrameFlags.PRIORITY, streamId);
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ namespace Microsoft.AspNetCore.Internal
|
|||
{
|
||||
public class SyncPoint
|
||||
{
|
||||
private readonly TaskCompletionSource<object> _atSyncPoint = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private readonly TaskCompletionSource<object> _continueFromSyncPoint = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private readonly TaskCompletionSource _atSyncPoint = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private readonly TaskCompletionSource _continueFromSyncPoint = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
/// <summary>
|
||||
/// Waits for the code-under-test to reach <see cref="WaitToContinue"/>.
|
||||
|
|
@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Internal
|
|||
/// <summary>
|
||||
/// Releases the code-under-test to continue past where it waited for <see cref="WaitToContinue"/>.
|
||||
/// </summary>
|
||||
public void Continue() => _continueFromSyncPoint.TrySetResult(null);
|
||||
public void Continue() => _continueFromSyncPoint.TrySetResult();
|
||||
|
||||
/// <summary>
|
||||
/// Used by the code-under-test to wait for the test code to sync up.
|
||||
|
|
@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.Internal
|
|||
/// <returns></returns>
|
||||
public Task WaitToContinue()
|
||||
{
|
||||
_atSyncPoint.TrySetResult(null);
|
||||
_atSyncPoint.TrySetResult();
|
||||
return _continueFromSyncPoint.Task;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -316,7 +316,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
const string originalMessage = "SignalR";
|
||||
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
var restartTcs = new TaskCompletionSource<object>();
|
||||
var restartTcs = new TaskCompletionSource();
|
||||
connection.Closed += async e =>
|
||||
{
|
||||
try
|
||||
|
|
@ -327,7 +327,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
logger.LogInformation("Restarting connection");
|
||||
await connection.StartAsync().OrTimeout();
|
||||
logger.LogInformation("Restarted connection");
|
||||
restartTcs.SetResult(null);
|
||||
restartTcs.SetResult();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -716,7 +716,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
using (var server = await StartServer<Startup>())
|
||||
{
|
||||
var connection = CreateHubConnection(server.Url, path, transportType, protocol, LoggerFactory);
|
||||
var closeTcs = new TaskCompletionSource<object>();
|
||||
var closeTcs = new TaskCompletionSource();
|
||||
connection.Closed += e =>
|
||||
{
|
||||
if (e != null)
|
||||
|
|
@ -725,7 +725,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
}
|
||||
else
|
||||
{
|
||||
closeTcs.SetResult(null);
|
||||
closeTcs.SetResult();
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
|
@ -1881,12 +1881,12 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
try
|
||||
{
|
||||
var echoMessage = "test";
|
||||
var reconnectingTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var reconnectingTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var reconnectedTcs = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
connection.Reconnecting += _ =>
|
||||
{
|
||||
reconnectingTcs.SetResult(null);
|
||||
reconnectingTcs.SetResult();
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
|
|
@ -1942,12 +1942,12 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
try
|
||||
{
|
||||
var echoMessage = "test";
|
||||
var reconnectingTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var reconnectingTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var reconnectedTcs = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
connection.Reconnecting += _ =>
|
||||
{
|
||||
reconnectingTcs.SetResult(null);
|
||||
reconnectingTcs.SetResult();
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
|
|
@ -2008,12 +2008,12 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
try
|
||||
{
|
||||
var echoMessage = "test";
|
||||
var reconnectingTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var reconnectingTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var reconnectedTcs = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
connection.Reconnecting += _ =>
|
||||
{
|
||||
reconnectingTcs.SetResult(null);
|
||||
reconnectingTcs.SetResult();
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
DefaultTransferFormat = TransferFormat.Text
|
||||
}),
|
||||
LoggerFactory);
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var tcs = new TaskCompletionSource();
|
||||
|
||||
var proxyConnectionFactory = new ProxyConnectionFactory(httpConnectionFactory);
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
var connection = connectionBuilder.Build();
|
||||
connection.On("NewProtocolMethodClient", () =>
|
||||
{
|
||||
tcs.SetResult(null);
|
||||
tcs.SetResult();
|
||||
});
|
||||
|
||||
try
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
{
|
||||
var httpHandler = new TestHttpMessageHandler();
|
||||
|
||||
var connectResponseTcs = new TaskCompletionSource<object>();
|
||||
var connectResponseTcs = new TaskCompletionSource();
|
||||
httpHandler.OnGet("/?id=00000000-0000-0000-0000-000000000000", async (_, __) =>
|
||||
{
|
||||
await connectResponseTcs.Task;
|
||||
|
|
@ -374,7 +374,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
var startTask = connection.StartAsync();
|
||||
Assert.False(connectResponseTcs.Task.IsCompleted);
|
||||
Assert.False(startTask.IsCompleted);
|
||||
connectResponseTcs.TrySetResult(null);
|
||||
connectResponseTcs.TrySetResult();
|
||||
await startTask.OrTimeout();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -266,10 +266,10 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
var testConnection = new TestConnection();
|
||||
await AsyncUsing(CreateHubConnection(testConnection), async connection =>
|
||||
{
|
||||
var closed = new TaskCompletionSource<object>();
|
||||
var closed = new TaskCompletionSource();
|
||||
connection.Closed += exception =>
|
||||
{
|
||||
closed.TrySetResult(null);
|
||||
closed.TrySetResult();
|
||||
Assert.Equal(HubConnectionState.Disconnected, connection.State);
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
|
@ -358,12 +358,12 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
public async Task CompletingTheTransportSideMarksConnectionAsClosed()
|
||||
{
|
||||
var testConnection = new TestConnection();
|
||||
var closed = new TaskCompletionSource<object>();
|
||||
var closed = new TaskCompletionSource();
|
||||
await AsyncUsing(CreateHubConnection(testConnection), async connection =>
|
||||
{
|
||||
connection.Closed += (e) =>
|
||||
{
|
||||
closed.TrySetResult(null);
|
||||
closed.TrySetResult();
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
await connection.StartAsync().OrTimeout();
|
||||
|
|
@ -383,13 +383,12 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
public async Task TransportCompletionWhileShuttingDownIsNoOp()
|
||||
{
|
||||
var testConnection = new TestConnection();
|
||||
var testConnectionClosed = new TaskCompletionSource<object>();
|
||||
var connectionClosed = new TaskCompletionSource<object>();
|
||||
var connectionClosed = new TaskCompletionSource();
|
||||
await AsyncUsing(CreateHubConnection(testConnection), async connection =>
|
||||
{
|
||||
connection.Closed += (e) =>
|
||||
{
|
||||
connectionClosed.TrySetResult(null);
|
||||
connectionClosed.TrySetResult();
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
|
|
@ -423,12 +422,12 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
public async Task StopAsyncDuringUnderlyingConnectionCloseWaitsAndNoOps()
|
||||
{
|
||||
var testConnection = new TestConnection();
|
||||
var connectionClosed = new TaskCompletionSource<object>();
|
||||
var connectionClosed = new TaskCompletionSource();
|
||||
await AsyncUsing(CreateHubConnection(testConnection), async connection =>
|
||||
{
|
||||
connection.Closed += (e) =>
|
||||
{
|
||||
connectionClosed.TrySetResult(null);
|
||||
connectionClosed.TrySetResult();
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
writeContext.EventId.Name == "ReconnectingWithError");
|
||||
}
|
||||
|
||||
var failReconnectTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var failReconnectTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
using (StartVerifiableLog(ExpectedErrors))
|
||||
{
|
||||
|
|
@ -188,7 +188,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
writeContext.EventId.Name == "ReconnectingWithError");
|
||||
}
|
||||
|
||||
var failReconnectTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var failReconnectTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
using (StartVerifiableLog(ExpectedErrors))
|
||||
{
|
||||
|
|
@ -378,13 +378,11 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
writeContext.EventId.Name == "ReconnectingWithError");
|
||||
}
|
||||
|
||||
var failReconnectTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
using (StartVerifiableLog(ExpectedErrors))
|
||||
{
|
||||
var builder = new HubConnectionBuilder().WithLoggerFactory(LoggerFactory).WithUrl("http://example.com");
|
||||
var testConnectionFactory = default(ReconnectingConnectionFactory);
|
||||
|
||||
|
||||
testConnectionFactory = new ReconnectingConnectionFactory(() => new TestConnection());
|
||||
builder.Services.AddSingleton<IConnectionFactory>(testConnectionFactory);
|
||||
|
||||
|
|
@ -464,13 +462,11 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
writeContext.EventId.Name == "ShutdownWithError");
|
||||
}
|
||||
|
||||
var failReconnectTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
using (StartVerifiableLog(ExpectedErrors))
|
||||
{
|
||||
var builder = new HubConnectionBuilder().WithLoggerFactory(LoggerFactory).WithUrl("http://example.com");
|
||||
var testConnectionFactory = default(ReconnectingConnectionFactory);
|
||||
|
||||
|
||||
testConnectionFactory = new ReconnectingConnectionFactory(() => new TestConnection());
|
||||
builder.Services.AddSingleton<IConnectionFactory>(testConnectionFactory);
|
||||
|
||||
|
|
@ -647,7 +643,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
builder.Services.AddSingleton<IConnectionFactory>(testConnectionFactory);
|
||||
|
||||
var retryContexts = new List<RetryContext>();
|
||||
var secondRetryDelayTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var secondRetryDelayTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var mockReconnectPolicy = new Mock<IRetryPolicy>();
|
||||
mockReconnectPolicy.Setup(p => p.NextRetryDelay(It.IsAny<RetryContext>())).Returns<RetryContext>(context =>
|
||||
{
|
||||
|
|
@ -655,7 +651,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
|
||||
if (retryContexts.Count == 2)
|
||||
{
|
||||
secondRetryDelayTcs.SetResult(null);
|
||||
secondRetryDelayTcs.SetResult();
|
||||
}
|
||||
|
||||
return TimeSpan.Zero;
|
||||
|
|
@ -754,7 +750,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
builder.Services.AddSingleton<IConnectionFactory>(testConnectionFactory);
|
||||
|
||||
var retryContexts = new List<RetryContext>();
|
||||
var secondRetryDelayTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var secondRetryDelayTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var mockReconnectPolicy = new Mock<IRetryPolicy>();
|
||||
mockReconnectPolicy.Setup(p => p.NextRetryDelay(It.IsAny<RetryContext>())).Returns<RetryContext>(context =>
|
||||
{
|
||||
|
|
@ -762,7 +758,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
|
||||
if (retryContexts.Count == 2)
|
||||
{
|
||||
secondRetryDelayTcs.SetResult(null);
|
||||
secondRetryDelayTcs.SetResult();
|
||||
}
|
||||
|
||||
return TimeSpan.Zero;
|
||||
|
|
@ -869,7 +865,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
using (StartVerifiableLog(ExpectedErrors))
|
||||
{
|
||||
var builder = new HubConnectionBuilder().WithLoggerFactory(LoggerFactory).WithUrl("http://example.com");
|
||||
var connectionStartTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var connectionStartTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
async Task OnTestConnectionStart()
|
||||
{
|
||||
|
|
@ -879,7 +875,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
}
|
||||
finally
|
||||
{
|
||||
connectionStartTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
connectionStartTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -921,7 +917,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
};
|
||||
|
||||
// Allow the first connection to start successfully.
|
||||
connectionStartTcs.SetResult(null);
|
||||
connectionStartTcs.SetResult();
|
||||
await hubConnection.StartAsync().OrTimeout();
|
||||
|
||||
var firstException = new Exception();
|
||||
|
|
@ -935,7 +931,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
|
||||
var secondException = new Exception();
|
||||
var stopTask = hubConnection.StopAsync();
|
||||
connectionStartTcs.SetResult(null);
|
||||
connectionStartTcs.SetResult();
|
||||
|
||||
Assert.IsType<OperationCanceledException>(await closedErrorTcs.Task.OrTimeout());
|
||||
Assert.Single(retryContexts);
|
||||
|
|
|
|||
|
|
@ -84,18 +84,18 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
var connection = new TestConnection();
|
||||
var hubConnection = CreateHubConnection(connection, loggerFactory: LoggerFactory);
|
||||
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
hubConnection.On("method", async () =>
|
||||
{
|
||||
await hubConnection.StopAsync().OrTimeout();
|
||||
tcs.SetResult(null);
|
||||
tcs.SetResult();
|
||||
});
|
||||
|
||||
await hubConnection.StartAsync().OrTimeout();
|
||||
|
||||
await connection.ReceiveJsonMessage(new { type = HubProtocolConstants.InvocationMessageType, target= "method", arguments = new object[] { } }).OrTimeout();
|
||||
|
||||
Assert.Null(await tcs.Task.OrTimeout());
|
||||
await tcs.Task.OrTimeout();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -104,11 +104,11 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
var connection = new TestConnection();
|
||||
var hubConnection = CreateHubConnection(connection, loggerFactory: LoggerFactory);
|
||||
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var methodCalledTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var methodCalledTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
hubConnection.On("method", async () =>
|
||||
{
|
||||
methodCalledTcs.SetResult(null);
|
||||
methodCalledTcs.SetResult();
|
||||
await tcs.Task;
|
||||
});
|
||||
|
||||
|
|
@ -119,7 +119,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
await methodCalledTcs.Task.OrTimeout();
|
||||
await hubConnection.StopAsync().OrTimeout();
|
||||
|
||||
tcs.SetResult(null);
|
||||
tcs.SetResult();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -559,7 +559,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
var hubConnection = CreateHubConnection(connection, loggerFactory: LoggerFactory);
|
||||
await hubConnection.StartAsync().OrTimeout();
|
||||
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
hubConnection.On<string>("Echo", async msg =>
|
||||
{
|
||||
try
|
||||
|
|
@ -573,13 +573,13 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
return;
|
||||
}
|
||||
|
||||
tcs.SetResult(null);
|
||||
tcs.SetResult();
|
||||
});
|
||||
|
||||
var closedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var closedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
hubConnection.Closed += _ =>
|
||||
{
|
||||
closedTcs.SetResult(null);
|
||||
closedTcs.SetResult();
|
||||
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
[Fact]
|
||||
public async Task StopTransportWhenConnectionAlreadyStoppedOnServer()
|
||||
{
|
||||
var pollRequestTcs = new TaskCompletionSource<object>();
|
||||
var pollRequestTcs = new TaskCompletionSource();
|
||||
|
||||
var mockHttpHandler = new Mock<HttpMessageHandler>();
|
||||
var firstPoll = true;
|
||||
|
|
@ -259,7 +259,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
|
||||
var stopTask = longPollingTransport.StopAsync();
|
||||
|
||||
pollRequestTcs.SetResult(null);
|
||||
pollRequestTcs.SetResult();
|
||||
|
||||
await stopTask.OrTimeout();
|
||||
}
|
||||
|
|
@ -520,7 +520,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
{
|
||||
var sentRequests = new List<byte[]>();
|
||||
var pollTcs = new TaskCompletionSource<HttpResponseMessage>();
|
||||
var deleteTcs = new TaskCompletionSource<object>();
|
||||
var deleteTcs = new TaskCompletionSource();
|
||||
var firstPoll = true;
|
||||
|
||||
var mockHttpHandler = new Mock<HttpMessageHandler>();
|
||||
|
|
@ -552,7 +552,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
// The poll task should have been completed
|
||||
Assert.True(pollTcs.Task.IsCompleted);
|
||||
|
||||
deleteTcs.TrySetResult(null);
|
||||
deleteTcs.TrySetResult();
|
||||
|
||||
return ResponseUtils.CreateResponse(HttpStatusCode.Accepted);
|
||||
}
|
||||
|
|
@ -632,7 +632,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
public async Task LongPollingTransportRePollsIfRequestCanceled()
|
||||
{
|
||||
var numPolls = 0;
|
||||
var completionTcs = new TaskCompletionSource<object>();
|
||||
var completionTcs = new TaskCompletionSource();
|
||||
|
||||
var mockHttpHandler = new Mock<HttpMessageHandler>();
|
||||
mockHttpHandler.Protected()
|
||||
|
|
@ -652,7 +652,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
throw new OperationCanceledException();
|
||||
}
|
||||
|
||||
completionTcs.SetResult(null);
|
||||
completionTcs.SetResult();
|
||||
return ResponseUtils.CreateResponse(HttpStatusCode.OK);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
[Fact]
|
||||
public async Task CanStartStopSSETransport()
|
||||
{
|
||||
var eventStreamTcs = new TaskCompletionSource<object>();
|
||||
var copyToAsyncTcs = new TaskCompletionSource<int>();
|
||||
var eventStreamTcs = new TaskCompletionSource();
|
||||
var copyToAsyncTcs = new TaskCompletionSource();
|
||||
|
||||
var mockHttpHandler = new Mock<HttpMessageHandler>();
|
||||
mockHttpHandler.Protected()
|
||||
|
|
@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
{
|
||||
await Task.Yield();
|
||||
// Receive loop started - allow stopping the transport
|
||||
eventStreamTcs.SetResult(null);
|
||||
eventStreamTcs.SetResult();
|
||||
|
||||
// returns unfinished task to block pipelines
|
||||
var mockStream = new Mock<Stream>();
|
||||
|
|
@ -62,7 +62,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
}
|
||||
finally
|
||||
{
|
||||
copyToAsyncTcs.SetResult(0);
|
||||
copyToAsyncTcs.SetResult();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -171,7 +171,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
writeContext.EventId.Name == "ErrorSending";
|
||||
}
|
||||
|
||||
var eventStreamTcs = new TaskCompletionSource<object>();
|
||||
var eventStreamTcs = new TaskCompletionSource();
|
||||
var readTcs = new TaskCompletionSource<int>();
|
||||
|
||||
var mockHttpHandler = new Mock<HttpMessageHandler>();
|
||||
|
|
@ -184,7 +184,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
if (request.Headers.Accept?.Contains(new MediaTypeWithQualityHeaderValue("text/event-stream")) == true)
|
||||
{
|
||||
// Receive loop started - allow stopping the transport
|
||||
eventStreamTcs.SetResult(null);
|
||||
eventStreamTcs.SetResult();
|
||||
|
||||
// returns unfinished task to block pipelines
|
||||
var mockStream = new Mock<Stream>();
|
||||
|
|
@ -226,7 +226,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
[Fact]
|
||||
public async Task SSETransportStopsIfChannelClosed()
|
||||
{
|
||||
var eventStreamTcs = new TaskCompletionSource<object>();
|
||||
var eventStreamTcs = new TaskCompletionSource();
|
||||
var readTcs = new TaskCompletionSource<int>();
|
||||
|
||||
var mockHttpHandler = new Mock<HttpMessageHandler>();
|
||||
|
|
@ -237,7 +237,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
await Task.Yield();
|
||||
|
||||
// Receive loop started - allow stopping the transport
|
||||
eventStreamTcs.SetResult(null);
|
||||
eventStreamTcs.SetResult();
|
||||
|
||||
// returns unfinished task to block pipelines
|
||||
var mockStream = new Mock<Stream>();
|
||||
|
|
@ -299,8 +299,8 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
[Fact]
|
||||
public async Task SSETransportCancelsSendOnStop()
|
||||
{
|
||||
var eventStreamTcs = new TaskCompletionSource<object>();
|
||||
var readTcs = new TaskCompletionSource<object>();
|
||||
var eventStreamTcs = new TaskCompletionSource();
|
||||
var readTcs = new TaskCompletionSource();
|
||||
var sendSyncPoint = new SyncPoint();
|
||||
|
||||
var mockHttpHandler = new Mock<HttpMessageHandler>();
|
||||
|
|
@ -313,7 +313,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
if (request.Headers.Accept?.Contains(new MediaTypeWithQualityHeaderValue("text/event-stream")) == true)
|
||||
{
|
||||
// Receive loop started - allow stopping the transport
|
||||
eventStreamTcs.SetResult(null);
|
||||
eventStreamTcs.SetResult();
|
||||
|
||||
// returns unfinished task to block pipelines
|
||||
var mockStream = new Mock<Stream>();
|
||||
|
|
@ -351,7 +351,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
|
||||
var stopTask = sseTransport.StopAsync();
|
||||
|
||||
readTcs.SetResult(null);
|
||||
readTcs.SetResult();
|
||||
sendSyncPoint.Continue();
|
||||
|
||||
await stopTask;
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
internal class TestConnection : ConnectionContext, IConnectionInherentKeepAliveFeature
|
||||
{
|
||||
private readonly bool _autoHandshake;
|
||||
private readonly TaskCompletionSource<object> _started = new TaskCompletionSource<object>();
|
||||
private readonly TaskCompletionSource<object> _disposed = new TaskCompletionSource<object>();
|
||||
private readonly TaskCompletionSource _started = new TaskCompletionSource();
|
||||
private readonly TaskCompletionSource _disposed = new TaskCompletionSource();
|
||||
|
||||
private int _disposeCount = 0;
|
||||
public Task Started => _started.Task;
|
||||
|
|
@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
|
||||
public async ValueTask<ConnectionContext> StartAsync()
|
||||
{
|
||||
_started.TrySetResult(null);
|
||||
_started.TrySetResult();
|
||||
|
||||
await _onStart();
|
||||
|
||||
|
|
@ -204,7 +204,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
private async ValueTask DisposeCoreAsync(Exception ex = null)
|
||||
{
|
||||
Interlocked.Increment(ref _disposeCount);
|
||||
_disposed.TrySetResult(null);
|
||||
_disposed.TrySetResult();
|
||||
await _onDispose();
|
||||
|
||||
// Simulate HttpConnection's behavior by Completing the Transport pipe.
|
||||
|
|
|
|||
|
|
@ -111,8 +111,8 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, deleteCts.Token);
|
||||
|
||||
// Just block until canceled
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
using (cts.Token.Register(() => tcs.TrySetResult(null)))
|
||||
var tcs = new TaskCompletionSource();
|
||||
using (cts.Token.Register(() => tcs.TrySetResult()))
|
||||
{
|
||||
await tcs.Task;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
[QuarantinedTest]
|
||||
public async Task FinalizerRunsIfTimerAwaitableReferencesObject()
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
UseTimerAwaitableAndUnref(tcs);
|
||||
|
||||
GC.Collect();
|
||||
|
|
@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private void UseTimerAwaitableAndUnref(TaskCompletionSource<object> tcs)
|
||||
private void UseTimerAwaitableAndUnref(TaskCompletionSource tcs)
|
||||
{
|
||||
_ = new ObjectWithTimerAwaitable(tcs).Start();
|
||||
}
|
||||
|
|
@ -38,9 +38,9 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
public class ObjectWithTimerAwaitable
|
||||
{
|
||||
private readonly TimerAwaitable _timer;
|
||||
private readonly TaskCompletionSource<object> _tcs;
|
||||
private readonly TaskCompletionSource _tcs;
|
||||
|
||||
public ObjectWithTimerAwaitable(TaskCompletionSource<object> tcs)
|
||||
public ObjectWithTimerAwaitable(TaskCompletionSource tcs)
|
||||
{
|
||||
_tcs = tcs;
|
||||
_timer = new TimerAwaitable(TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(1));
|
||||
|
|
@ -59,7 +59,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
|
|||
|
||||
~ObjectWithTimerAwaitable()
|
||||
{
|
||||
_tcs.TrySetResult(null);
|
||||
_tcs.TrySetResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
|
|||
|
||||
// This tcs exists so that multiple calls to DisposeAsync all wait asynchronously
|
||||
// on the same task
|
||||
private readonly TaskCompletionSource<object> _disposeTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private readonly TaskCompletionSource _disposeTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
/// <summary>
|
||||
/// Creates the DefaultConnectionContext without Pipes to avoid upfront allocations.
|
||||
|
|
@ -330,7 +330,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
|
|||
}
|
||||
|
||||
// Notify all waiters that we're done disposing
|
||||
_disposeTcs.TrySetResult(null);
|
||||
_disposeTcs.TrySetResult();
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
|
|||
}
|
||||
|
||||
// Create a new Tcs every poll to keep track of the poll finishing, so we can properly wait on previous polls
|
||||
var currentRequestTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var currentRequestTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
if (!connection.TryActivateLongPollingConnection(
|
||||
connectionDelegate, context, options.LongPolling.PollTimeout,
|
||||
|
|
@ -254,7 +254,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
|
|||
{
|
||||
// Artificial task queue
|
||||
// This will cause incoming polls to wait until the previous poll has finished updating internal state info
|
||||
currentRequestTcs.TrySetResult(null);
|
||||
currentRequestTcs.TrySetResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1385,7 +1385,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
|
||||
// Manually control PreviousPollTask instead of using a real PreviousPollTask, because a real
|
||||
// PreviousPollTask might complete too early when the second request cancels it.
|
||||
var lastPollTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var lastPollTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
connection.PreviousPollTask = lastPollTcs.Task;
|
||||
|
||||
request1 = dispatcher.ExecuteAsync(context1, options, app);
|
||||
|
|
@ -1394,7 +1394,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
Assert.False(request1.IsCompleted);
|
||||
Assert.False(request2.IsCompleted);
|
||||
|
||||
lastPollTcs.SetResult(null);
|
||||
lastPollTcs.SetResult();
|
||||
|
||||
var completedTask = await Task.WhenAny(request1, request2).OrTimeout();
|
||||
|
||||
|
|
@ -1977,18 +1977,18 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
var connection = manager.CreateConnection();
|
||||
connection.TransportType = transportType;
|
||||
|
||||
var waitForMessageTcs1 = new TaskCompletionSource<object>();
|
||||
var messageTcs1 = new TaskCompletionSource<object>();
|
||||
var waitForMessageTcs2 = new TaskCompletionSource<object>();
|
||||
var messageTcs2 = new TaskCompletionSource<object>();
|
||||
var waitForMessageTcs1 = new TaskCompletionSource();
|
||||
var messageTcs1 = new TaskCompletionSource();
|
||||
var waitForMessageTcs2 = new TaskCompletionSource();
|
||||
var messageTcs2 = new TaskCompletionSource();
|
||||
ConnectionDelegate connectionDelegate = async c =>
|
||||
{
|
||||
await waitForMessageTcs1.Task.OrTimeout();
|
||||
await c.Transport.Output.WriteAsync(Encoding.UTF8.GetBytes("Message1")).OrTimeout();
|
||||
messageTcs1.TrySetResult(null);
|
||||
messageTcs1.TrySetResult();
|
||||
await waitForMessageTcs2.Task.OrTimeout();
|
||||
await c.Transport.Output.WriteAsync(Encoding.UTF8.GetBytes("Message2")).OrTimeout();
|
||||
messageTcs2.TrySetResult(null);
|
||||
messageTcs2.TrySetResult();
|
||||
};
|
||||
{
|
||||
var options = new HttpConnectionDispatcherOptions();
|
||||
|
|
@ -1996,7 +1996,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
await dispatcher.ExecuteAsync(context, options, connectionDelegate).OrTimeout();
|
||||
|
||||
// second poll should have data
|
||||
waitForMessageTcs1.SetResult(null);
|
||||
waitForMessageTcs1.SetResult();
|
||||
await messageTcs1.Task.OrTimeout();
|
||||
|
||||
var ms = new MemoryStream();
|
||||
|
|
@ -2005,7 +2005,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
await dispatcher.ExecuteAsync(context, options, connectionDelegate).OrTimeout();
|
||||
Assert.Equal("Message1", Encoding.UTF8.GetString(ms.ToArray()));
|
||||
|
||||
waitForMessageTcs2.SetResult(null);
|
||||
waitForMessageTcs2.SetResult();
|
||||
await messageTcs2.Task.OrTimeout();
|
||||
|
||||
context = MakeRequest("/foo", connection);
|
||||
|
|
@ -2372,7 +2372,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
{
|
||||
public override Task OnConnectedAsync(ConnectionContext connection)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var tcs = new TaskCompletionSource();
|
||||
return tcs.Task;
|
||||
}
|
||||
}
|
||||
|
|
@ -2438,13 +2438,13 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
|
||||
public class TestConnectionHandler : ConnectionHandler
|
||||
{
|
||||
private TaskCompletionSource<object> _startedTcs = new TaskCompletionSource<object>();
|
||||
private TaskCompletionSource _startedTcs = new TaskCompletionSource();
|
||||
|
||||
public Task Started => _startedTcs.Task;
|
||||
|
||||
public override async Task OnConnectedAsync(ConnectionContext connection)
|
||||
{
|
||||
_startedTcs.TrySetResult(null);
|
||||
_startedTcs.TrySetResult();
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -94,11 +94,6 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
connection.TransportTask = Task.CompletedTask;
|
||||
}
|
||||
|
||||
var applicationInputTcs = new TaskCompletionSource<object>();
|
||||
var applicationOutputTcs = new TaskCompletionSource<object>();
|
||||
var transportInputTcs = new TaskCompletionSource<object>();
|
||||
var transportOutputTcs = new TaskCompletionSource<object>();
|
||||
|
||||
try
|
||||
{
|
||||
await connection.DisposeAsync(closeGracefully).OrTimeout();
|
||||
|
|
@ -269,7 +264,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
{
|
||||
var connectionManager = CreateConnectionManager(LoggerFactory);
|
||||
var connection = connectionManager.CreateConnection(PipeOptions.Default, PipeOptions.Default);
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
connection.ApplicationTask = tcs.Task;
|
||||
connection.TransportTask = tcs.Task;
|
||||
|
|
@ -279,7 +274,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
Assert.False(firstTask.IsCompleted);
|
||||
Assert.False(secondTask.IsCompleted);
|
||||
|
||||
tcs.TrySetResult(null);
|
||||
tcs.TrySetResult();
|
||||
|
||||
await Task.WhenAll(firstTask, secondTask).OrTimeout();
|
||||
}
|
||||
|
|
@ -292,7 +287,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
{
|
||||
var connectionManager = CreateConnectionManager(LoggerFactory);
|
||||
var connection = connectionManager.CreateConnection(PipeOptions.Default, PipeOptions.Default);
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
connection.ApplicationTask = tcs.Task;
|
||||
connection.TransportTask = tcs.Task;
|
||||
|
|
@ -319,7 +314,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
{
|
||||
var connectionManager = CreateConnectionManager(LoggerFactory);
|
||||
var connection = connectionManager.CreateConnection(PipeOptions.Default, PipeOptions.Default);
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
connection.ApplicationTask = tcs.Task;
|
||||
connection.TransportTask = tcs.Task;
|
||||
|
|
@ -376,7 +371,6 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
{
|
||||
var appLifetime = new TestApplicationLifetime();
|
||||
var connectionManager = CreateConnectionManager(LoggerFactory, appLifetime);
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
|
||||
appLifetime.Start();
|
||||
|
||||
|
|
@ -398,7 +392,6 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
appLifetime.Start();
|
||||
|
||||
var connectionManager = CreateConnectionManager(LoggerFactory, appLifetime);
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
|
||||
var connection = connectionManager.CreateConnection(PipeOptions.Default, PipeOptions.Default);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
}
|
||||
|
||||
private readonly SyncPoint _sync;
|
||||
private readonly TaskCompletionSource<object> _accepted = new TaskCompletionSource<object>();
|
||||
private readonly TaskCompletionSource _accepted = new TaskCompletionSource();
|
||||
|
||||
public bool IsWebSocketRequest => true;
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
|
|||
Client = clientSocket;
|
||||
SubProtocol = context.SubProtocol;
|
||||
|
||||
_accepted.TrySetResult(null);
|
||||
_accepted.TrySetResult();
|
||||
return Task.FromResult<WebSocket>(serverSocket);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Threading;
|
||||
|
|
@ -10,10 +10,10 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
{
|
||||
public static Task WaitForCancellationAsync(this CancellationToken token)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
token.Register((t) =>
|
||||
{
|
||||
((TaskCompletionSource<object>)t).SetResult(null);
|
||||
((TaskCompletionSource)t).SetResult();
|
||||
}, tcs);
|
||||
return tcs.Task;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
|
|||
|
||||
public class NoErrorHubConnectionContext : HubConnectionContext
|
||||
{
|
||||
public TaskCompletionSource<object> ReceivedCompleted = new TaskCompletionSource<object>();
|
||||
public TaskCompletionSource ReceivedCompleted = new TaskCompletionSource();
|
||||
|
||||
public NoErrorHubConnectionContext(ConnectionContext connectionContext, HubConnectionContextOptions contextOptions, ILoggerFactory loggerFactory)
|
||||
: base(connectionContext, contextOptions, loggerFactory)
|
||||
|
|
@ -94,7 +94,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
|
|||
{
|
||||
if (message is CompletionMessage completionMessage)
|
||||
{
|
||||
ReceivedCompleted.TrySetResult(null);
|
||||
ReceivedCompleted.TrySetResult();
|
||||
|
||||
if (!string.IsNullOrEmpty(completionMessage.Error))
|
||||
{
|
||||
|
|
@ -264,7 +264,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
|
|||
await _dispatcher.DispatchMessageAsync(_connectionContext, new StreamInvocationMessage("123", "StreamChannelReaderCount", new object[] { 0 }));
|
||||
|
||||
await (_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted.Task;
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource<object>();
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource();
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
|
|
@ -273,7 +273,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
|
|||
await _dispatcher.DispatchMessageAsync(_connectionContext, new StreamInvocationMessage("123", "StreamIAsyncEnumerableCount", new object[] { 0 }));
|
||||
|
||||
await (_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted.Task;
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource<object>();
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource();
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
|
|
@ -282,7 +282,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
|
|||
await _dispatcher.DispatchMessageAsync(_connectionContext, new StreamInvocationMessage("123", "StreamIAsyncEnumerableCountCompletedTask", new object[] { 0 }));
|
||||
|
||||
await (_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted.Task;
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource<object>();
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource();
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
|
|
@ -291,7 +291,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
|
|||
await _dispatcher.DispatchMessageAsync(_connectionContext, new StreamInvocationMessage("123", "StreamChannelReaderCount", new object[] { 1 }));
|
||||
|
||||
await (_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted.Task;
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource<object>();
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource();
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
|
|
@ -300,7 +300,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
|
|||
await _dispatcher.DispatchMessageAsync(_connectionContext, new StreamInvocationMessage("123", "StreamIAsyncEnumerableCount", new object[] { 1 }));
|
||||
|
||||
await (_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted.Task;
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource<object>();
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource();
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
|
|
@ -309,7 +309,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
|
|||
await _dispatcher.DispatchMessageAsync(_connectionContext, new StreamInvocationMessage("123", "StreamIAsyncEnumerableCountCompletedTask", new object[] { 1 }));
|
||||
|
||||
await (_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted.Task;
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource<object>();
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource();
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
|
|
@ -318,7 +318,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
|
|||
await _dispatcher.DispatchMessageAsync(_connectionContext, new StreamInvocationMessage("123", "StreamChannelReaderCount", new object[] { 1000 }));
|
||||
|
||||
await (_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted.Task;
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource<object>();
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource();
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
|
|
@ -327,7 +327,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
|
|||
await _dispatcher.DispatchMessageAsync(_connectionContext, new StreamInvocationMessage("123", "StreamIAsyncEnumerableCount", new object[] { 1000 }));
|
||||
|
||||
await (_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted.Task;
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource<object>();
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource();
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
|
|
@ -336,7 +336,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
|
|||
await _dispatcher.DispatchMessageAsync(_connectionContext, new StreamInvocationMessage("123", "StreamIAsyncEnumerableCountCompletedTask", new object[] { 1000 }));
|
||||
|
||||
await (_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted.Task;
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource<object>();
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource();
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
|
|
@ -347,7 +347,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
|
|||
await _dispatcher.DispatchMessageAsync(_connectionContext, CompletionMessage.Empty("1"));
|
||||
|
||||
await (_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted.Task;
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource<object>();
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource();
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
|
|
@ -358,7 +358,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
|
|||
await _dispatcher.DispatchMessageAsync(_connectionContext, CompletionMessage.Empty("1"));
|
||||
|
||||
await (_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted.Task;
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource<object>();
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource();
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
|
|
@ -372,7 +372,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
|
|||
await _dispatcher.DispatchMessageAsync(_connectionContext, CompletionMessage.Empty("1"));
|
||||
|
||||
await (_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted.Task;
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource<object>();
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource();
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
|
|
@ -386,7 +386,7 @@ namespace Microsoft.AspNetCore.SignalR.Microbenchmarks
|
|||
await _dispatcher.DispatchMessageAsync(_connectionContext, CompletionMessage.Empty("1"));
|
||||
|
||||
await (_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted.Task;
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource<object>();
|
||||
(_connectionContext as NoErrorHubConnectionContext).ReceivedCompleted = new TaskCompletionSource();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@ namespace JwtClientSample
|
|||
})
|
||||
.Build();
|
||||
|
||||
var closedTcs = new TaskCompletionSource<object>();
|
||||
var closedTcs = new TaskCompletionSource();
|
||||
hubConnection.Closed += e =>
|
||||
{
|
||||
closedTcs.SetResult(null);
|
||||
closedTcs.SetResult();
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
private readonly ConnectionContext _connectionContext;
|
||||
private readonly ILogger _logger;
|
||||
private readonly CancellationTokenSource _connectionAbortedTokenSource = new CancellationTokenSource();
|
||||
private readonly TaskCompletionSource<object> _abortCompletedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private readonly TaskCompletionSource _abortCompletedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
private readonly long _keepAliveInterval;
|
||||
private readonly long _clientTimeoutInterval;
|
||||
private readonly SemaphoreSlim _writeLock = new SemaphoreSlim(1);
|
||||
|
|
@ -640,7 +640,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
{
|
||||
// Communicate the fact that we're finished triggering abort callbacks
|
||||
// HubOnDisconnectedAsync is waiting on this to complete the Pipe
|
||||
connection._abortCompletedTcs.TrySetResult(null);
|
||||
connection._abortCompletedTcs.TrySetResult();
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
Assert.Equal("Hello", message.Target);
|
||||
Assert.Single(message.Arguments);
|
||||
Assert.Equal("World", (string)message.Arguments[0]);
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
connection2.ConnectionAborted.Register(t =>
|
||||
{
|
||||
((TaskCompletionSource<object>)t).SetResult(null);
|
||||
((TaskCompletionSource)t).SetResult();
|
||||
}, tcs);
|
||||
await tcs.Task.OrTimeout();
|
||||
Assert.False(connection1.ConnectionAborted.IsCancellationRequested);
|
||||
|
|
@ -65,10 +65,10 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
Assert.False(sendTask.IsCompleted);
|
||||
cts.Cancel();
|
||||
await sendTask.OrTimeout();
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
connection2.ConnectionAborted.Register(t =>
|
||||
{
|
||||
((TaskCompletionSource<object>)t).SetResult(null);
|
||||
((TaskCompletionSource)t).SetResult();
|
||||
}, tcs);
|
||||
await tcs.Task.OrTimeout();
|
||||
Assert.False(connection1.ConnectionAborted.IsCancellationRequested);
|
||||
|
|
@ -89,10 +89,10 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
Assert.False(sendTask.IsCompleted);
|
||||
cts.Cancel();
|
||||
await sendTask.OrTimeout();
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
connection1.ConnectionAborted.Register(t =>
|
||||
{
|
||||
((TaskCompletionSource<object>)t).SetResult(null);
|
||||
((TaskCompletionSource)t).SetResult();
|
||||
}, tcs);
|
||||
await tcs.Task.OrTimeout();
|
||||
}
|
||||
|
|
@ -111,10 +111,10 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
Assert.False(sendTask.IsCompleted);
|
||||
cts.Cancel();
|
||||
await sendTask.OrTimeout();
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
connection1.ConnectionAborted.Register(t =>
|
||||
{
|
||||
((TaskCompletionSource<object>)t).SetResult(null);
|
||||
((TaskCompletionSource)t).SetResult();
|
||||
}, tcs);
|
||||
await tcs.Task.OrTimeout();
|
||||
}
|
||||
|
|
@ -134,10 +134,10 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
Assert.False(sendTask.IsCompleted);
|
||||
cts.Cancel();
|
||||
await sendTask.OrTimeout();
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
connection1.ConnectionAborted.Register(t =>
|
||||
{
|
||||
((TaskCompletionSource<object>)t).SetResult(null);
|
||||
((TaskCompletionSource)t).SetResult();
|
||||
}, tcs);
|
||||
await tcs.Task.OrTimeout();
|
||||
}
|
||||
|
|
@ -161,10 +161,10 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
Assert.False(sendTask.IsCompleted);
|
||||
cts.Cancel();
|
||||
await sendTask.OrTimeout();
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
connection2.ConnectionAborted.Register(t =>
|
||||
{
|
||||
((TaskCompletionSource<object>)t).SetResult(null);
|
||||
((TaskCompletionSource)t).SetResult();
|
||||
}, tcs);
|
||||
await tcs.Task.OrTimeout();
|
||||
Assert.False(connection1.ConnectionAborted.IsCancellationRequested);
|
||||
|
|
@ -186,10 +186,10 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
Assert.False(sendTask.IsCompleted);
|
||||
cts.Cancel();
|
||||
await sendTask.OrTimeout();
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
connection1.ConnectionAborted.Register(t =>
|
||||
{
|
||||
((TaskCompletionSource<object>)t).SetResult(null);
|
||||
((TaskCompletionSource)t).SetResult();
|
||||
}, tcs);
|
||||
await tcs.Task.OrTimeout();
|
||||
}
|
||||
|
|
@ -215,10 +215,10 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
Assert.Equal("Hello", message.Target);
|
||||
Assert.Single(message.Arguments);
|
||||
Assert.Equal("World", (string)message.Arguments[0]);
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
connection2.ConnectionAborted.Register(t =>
|
||||
{
|
||||
((TaskCompletionSource<object>)t).SetResult(null);
|
||||
((TaskCompletionSource)t).SetResult();
|
||||
}, tcs);
|
||||
await tcs.Task.OrTimeout();
|
||||
Assert.False(connection1.ConnectionAborted.IsCancellationRequested);
|
||||
|
|
@ -245,10 +245,10 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
Assert.Equal("Hello", message.Target);
|
||||
Assert.Single(message.Arguments);
|
||||
Assert.Equal("World", (string)message.Arguments[0]);
|
||||
var tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
connection2.ConnectionAborted.Register(t =>
|
||||
{
|
||||
((TaskCompletionSource<object>)t).SetResult(null);
|
||||
((TaskCompletionSource)t).SetResult();
|
||||
}, tcs);
|
||||
await tcs.Task.OrTimeout();
|
||||
Assert.False(connection1.ConnectionAborted.IsCancellationRequested);
|
||||
|
|
|
|||
|
|
@ -550,7 +550,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
.Build();
|
||||
try
|
||||
{
|
||||
var closeTcs = new TaskCompletionSource<object>();
|
||||
var closeTcs = new TaskCompletionSource();
|
||||
connection.Closed += e =>
|
||||
{
|
||||
if (e != null)
|
||||
|
|
@ -559,7 +559,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
}
|
||||
else
|
||||
{
|
||||
closeTcs.SetResult(null);
|
||||
closeTcs.SetResult();
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -510,7 +510,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
{
|
||||
public override Task OnConnectedAsync()
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var tcs = new TaskCompletionSource();
|
||||
tcs.SetException(new InvalidOperationException("Hub OnConnected failed."));
|
||||
return tcs.Task;
|
||||
}
|
||||
|
|
@ -520,7 +520,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
{
|
||||
public override Task OnDisconnectedAsync(Exception exception)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var tcs = new TaskCompletionSource();
|
||||
tcs.SetException(new InvalidOperationException("Hub OnDisconnected failed."));
|
||||
return tcs.Task;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2823,13 +2823,13 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
internal class PipeReaderWrapper : PipeReader
|
||||
{
|
||||
private readonly PipeReader _originalPipeReader;
|
||||
private TaskCompletionSource<object> _waitForRead;
|
||||
private TaskCompletionSource _waitForRead;
|
||||
private object _lock = new object();
|
||||
|
||||
public PipeReaderWrapper(PipeReader pipeReader)
|
||||
{
|
||||
_originalPipeReader = pipeReader;
|
||||
_waitForRead = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
_waitForRead = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
}
|
||||
|
||||
public override void AdvanceTo(SequencePosition consumed) =>
|
||||
|
|
@ -2848,7 +2848,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_waitForRead.SetResult(null);
|
||||
_waitForRead.SetResult();
|
||||
}
|
||||
|
||||
try
|
||||
|
|
@ -2859,7 +2859,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_waitForRead = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
_waitForRead = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4011,8 +4011,8 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
{
|
||||
public int ReleaseCount;
|
||||
private IServiceProvider _serviceProvider;
|
||||
public TaskCompletionSource<object> ReleaseTask = new TaskCompletionSource<object>();
|
||||
public TaskCompletionSource<object> CreateTask = new TaskCompletionSource<object>();
|
||||
public TaskCompletionSource ReleaseTask = new TaskCompletionSource();
|
||||
public TaskCompletionSource CreateTask = new TaskCompletionSource();
|
||||
|
||||
public CustomHubActivator(IServiceProvider serviceProvider)
|
||||
{
|
||||
|
|
@ -4021,9 +4021,9 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
|
||||
public THub Create()
|
||||
{
|
||||
ReleaseTask = new TaskCompletionSource<object>();
|
||||
ReleaseTask = new TaskCompletionSource();
|
||||
var hub = new DefaultHubActivator<THub>(_serviceProvider).Create();
|
||||
CreateTask.TrySetResult(null);
|
||||
CreateTask.TrySetResult();
|
||||
return hub;
|
||||
}
|
||||
|
||||
|
|
@ -4031,8 +4031,8 @@ namespace Microsoft.AspNetCore.SignalR.Tests
|
|||
{
|
||||
ReleaseCount++;
|
||||
hub.Dispose();
|
||||
ReleaseTask.TrySetResult(null);
|
||||
CreateTask = new TaskCompletionSource<object>();
|
||||
ReleaseTask.TrySetResult();
|
||||
CreateTask = new TaskCompletionSource();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests.Internal
|
|||
|
||||
public Task SendCoreAsync(string method, object[] args, CancellationToken cancellationToken)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<object>();
|
||||
var tcs = new TaskCompletionSource();
|
||||
|
||||
Sends.Add(new SendContext(method, args, cancellationToken, tcs));
|
||||
|
||||
|
|
@ -246,13 +246,13 @@ namespace Microsoft.AspNetCore.SignalR.Tests.Internal
|
|||
|
||||
private struct SendContext
|
||||
{
|
||||
private TaskCompletionSource<object> _tcs;
|
||||
private TaskCompletionSource _tcs;
|
||||
|
||||
public string Method { get; }
|
||||
public object[] Arguments { get; }
|
||||
public CancellationToken CancellationToken { get; }
|
||||
|
||||
public SendContext(string method, object[] arguments, CancellationToken cancellationToken, TaskCompletionSource<object> tcs) : this()
|
||||
public SendContext(string method, object[] arguments, CancellationToken cancellationToken, TaskCompletionSource tcs) : this()
|
||||
{
|
||||
Method = method;
|
||||
Arguments = arguments;
|
||||
|
|
@ -262,7 +262,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests.Internal
|
|||
|
||||
public void Complete()
|
||||
{
|
||||
_tcs.TrySetResult(null);
|
||||
_tcs.TrySetResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.SignalR.StackExchangeRedis.Internal
|
|||
{
|
||||
if (_acks.TryRemove(id, out var ack))
|
||||
{
|
||||
ack.Tcs.TrySetResult(null);
|
||||
ack.Tcs.TrySetResult();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -104,14 +104,14 @@ namespace Microsoft.AspNetCore.SignalR.StackExchangeRedis.Internal
|
|||
|
||||
private class AckInfo
|
||||
{
|
||||
public TaskCompletionSource<object> Tcs { get; private set; }
|
||||
public TaskCompletionSource Tcs { get; private set; }
|
||||
public DateTime Created { get; private set; }
|
||||
|
||||
public AckInfo()
|
||||
{
|
||||
Created = DateTime.UtcNow;
|
||||
Tcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
Tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue