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