Use correct TaskCompletionSource ctor (#2567)
This commit is contained in:
parent
b040e33b1b
commit
b64c0105b8
|
|
@ -441,13 +441,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
{
|
{
|
||||||
public LogLevel LastLogLevel { get; set; }
|
public LogLevel LastLogLevel { get; set; }
|
||||||
public EventId LastEventId { get; set; }
|
public EventId LastEventId { get; set; }
|
||||||
public TaskCompletionSource<object> LogTcs { get; } = new TaskCompletionSource<object>();
|
public TaskCompletionSource<object> LogTcs { get; } = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||||
|
|
||||||
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
|
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
|
||||||
{
|
{
|
||||||
LastLogLevel = logLevel;
|
LastLogLevel = logLevel;
|
||||||
LastEventId = eventId;
|
LastEventId = eventId;
|
||||||
Task.Run(() => LogTcs.SetResult(null));
|
LogTcs.SetResult(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsEnabled(LogLevel logLevel)
|
public bool IsEnabled(LogLevel logLevel)
|
||||||
|
|
|
||||||
|
|
@ -1217,10 +1217,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
const int connectionFinSentEventId = 7;
|
const int connectionFinSentEventId = 7;
|
||||||
const int maxRequestBufferSize = 4096;
|
const int maxRequestBufferSize = 4096;
|
||||||
|
|
||||||
var readCallbackUnwired = new TaskCompletionSource<object>(TaskContinuationOptions.RunContinuationsAsynchronously);
|
var readCallbackUnwired = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||||
var clientClosedConnection = new TaskCompletionSource<object>(TaskContinuationOptions.RunContinuationsAsynchronously);
|
var clientClosedConnection = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||||
var serverClosedConnection = new TaskCompletionSource<object>(TaskContinuationOptions.RunContinuationsAsynchronously);
|
var serverClosedConnection = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||||
var appFuncCompleted = new TaskCompletionSource<object>(TaskContinuationOptions.RunContinuationsAsynchronously);
|
var appFuncCompleted = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||||
|
|
||||||
var mockLogger = new Mock<ILogger>();
|
var mockLogger = new Mock<ILogger>();
|
||||||
mockLogger
|
mockLogger
|
||||||
|
|
@ -1276,9 +1276,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
|
|
||||||
await serverClosedConnection.Task;
|
await serverClosedConnection.Task;
|
||||||
|
|
||||||
// TaskContinuationOptions.RunContinuationsAsynchronously sometimes runs inline anyway in
|
appFuncCompleted.SetResult(null);
|
||||||
// situations such as this where the awaiter starts awaiting right when SetResult is called.
|
|
||||||
_ = Task.Run(() => appFuncCompleted.SetResult(null));
|
|
||||||
}, testContext, listenOptions))
|
}, testContext, listenOptions))
|
||||||
{
|
{
|
||||||
using (var connection = server.CreateConnection())
|
using (var connection = server.CreateConnection())
|
||||||
|
|
@ -1308,7 +1306,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
[MemberData(nameof(ConnectionAdapterData))]
|
[MemberData(nameof(ConnectionAdapterData))]
|
||||||
public async Task AppCanHandleClientAbortingConnectionMidRequest(ListenOptions listenOptions)
|
public async Task AppCanHandleClientAbortingConnectionMidRequest(ListenOptions listenOptions)
|
||||||
{
|
{
|
||||||
var readTcs = new TaskCompletionSource<Exception>(TaskContinuationOptions.RunContinuationsAsynchronously);
|
var readTcs = new TaskCompletionSource<Exception>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||||
|
|
||||||
var mockKestrelTrace = new Mock<KestrelTrace>(Logger) { CallBase = true };
|
var mockKestrelTrace = new Mock<KestrelTrace>(Logger) { CallBase = true };
|
||||||
var testContext = new TestServiceContext()
|
var testContext = new TestServiceContext()
|
||||||
|
|
|
||||||
|
|
@ -2337,9 +2337,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
const int maxRequestBufferSize = 4096;
|
const int maxRequestBufferSize = 4096;
|
||||||
|
|
||||||
var requestAborted = false;
|
var requestAborted = false;
|
||||||
var readCallbackUnwired = new TaskCompletionSource<object>(TaskContinuationOptions.RunContinuationsAsynchronously);
|
var readCallbackUnwired = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||||
var clientClosedConnection = new TaskCompletionSource<object>(TaskContinuationOptions.RunContinuationsAsynchronously);
|
var clientClosedConnection = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||||
var writeTcs = new TaskCompletionSource<Exception>(TaskContinuationOptions.RunContinuationsAsynchronously);
|
var writeTcs = new TaskCompletionSource<Exception>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||||
|
|
||||||
var mockKestrelTrace = new Mock<KestrelTrace>(Logger) { CallBase = true };
|
var mockKestrelTrace = new Mock<KestrelTrace>(Logger) { CallBase = true };
|
||||||
var mockLogger = new Mock<ILogger>();
|
var mockLogger = new Mock<ILogger>();
|
||||||
|
|
@ -2402,9 +2402,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
// TaskContinuationOptions.RunContinuationsAsynchronously sometimes runs inline anyway in
|
writeTcs.SetException(ex);
|
||||||
// situations such as this where the awaiter starts awaiting right when SetResult is called.
|
|
||||||
_ = Task.Run(() => writeTcs.SetException(ex));
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2444,7 +2442,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
const int responseBodySize = responseBodySegmentSize * responseBodySegmentCount;
|
const int responseBodySize = responseBodySegmentSize * responseBodySegmentCount;
|
||||||
|
|
||||||
var requestAborted = false;
|
var requestAborted = false;
|
||||||
var appCompletedTcs = new TaskCompletionSource<object>(TaskContinuationOptions.RunContinuationsAsynchronously);
|
var appCompletedTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||||
|
|
||||||
var mockKestrelTrace = new Mock<KestrelTrace>(Logger) { CallBase = true };
|
var mockKestrelTrace = new Mock<KestrelTrace>(Logger) { CallBase = true };
|
||||||
var testContext = new TestServiceContext()
|
var testContext = new TestServiceContext()
|
||||||
|
|
@ -2475,9 +2473,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
{
|
{
|
||||||
// WriteAsync shouldn't throw without a CancellationToken passed in. Unfortunately a ECONNRESET UvException sometimes gets thrown.
|
// WriteAsync shouldn't throw without a CancellationToken passed in. Unfortunately a ECONNRESET UvException sometimes gets thrown.
|
||||||
// This will be fixed by https://github.com/aspnet/KestrelHttpServer/pull/2547
|
// This will be fixed by https://github.com/aspnet/KestrelHttpServer/pull/2547
|
||||||
// TaskContinuationOptions.RunContinuationsAsynchronously sometimes runs inline anyway in
|
appCompletedTcs.SetResult(null);
|
||||||
// situations such as this where the awaiter starts awaiting right when SetResult is called.
|
|
||||||
_ = Task.Run(() => appCompletedTcs.SetResult(null));
|
|
||||||
}
|
}
|
||||||
}, testContext, listenOptions))
|
}, testContext, listenOptions))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue