Merge branch 'release/2.1' into dev
This commit is contained in:
commit
2ab22ac55a
|
|
@ -205,10 +205,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Performance
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void AbortCore(ConnectionAbortedException abortReason)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copied from https://github.com/aspnet/benchmarks/blob/dev/src/Benchmarks/Middleware/PlaintextMiddleware.cs
|
// Copied from https://github.com/aspnet/benchmarks/blob/dev/src/Benchmarks/Middleware/PlaintextMiddleware.cs
|
||||||
|
|
|
||||||
|
|
@ -25,5 +25,7 @@ namespace Microsoft.AspNetCore.Connections
|
||||||
// ConnectioContext.Abort()
|
// ConnectioContext.Abort()
|
||||||
Features.Get<IConnectionLifetimeFeature>()?.Abort();
|
Features.Get<IConnectionLifetimeFeature>()?.Abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void Abort() => Abort(new ConnectionAbortedException("The connection was aborted by the application."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,8 +65,6 @@ namespace Microsoft.AspNetCore.Connections
|
||||||
|
|
||||||
public CancellationToken ConnectionClosed { get; set; }
|
public CancellationToken ConnectionClosed { get; set; }
|
||||||
|
|
||||||
public void Abort() => Abort(abortReason: null);
|
|
||||||
|
|
||||||
public override void Abort(ConnectionAbortedException abortReason)
|
public override void Abort(ConnectionAbortedException abortReason)
|
||||||
{
|
{
|
||||||
ThreadPool.QueueUserWorkItem(cts => ((CancellationTokenSource)cts).Cancel(), _connectionClosedTokenSource);
|
ThreadPool.QueueUserWorkItem(cts => ((CancellationTokenSource)cts).Cancel(), _connectionClosedTokenSource);
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
|
||||||
(_, state) => ((HttpConnection)state).OnInputOrOutputCompleted(),
|
(_, state) => ((HttpConnection)state).OnInputOrOutputCompleted(),
|
||||||
connection);
|
connection);
|
||||||
|
|
||||||
await AsTask(lifetimeFeature.ConnectionClosed);
|
await CancellationTokenAsTask(lifetimeFeature.ConnectionClosed);
|
||||||
|
|
||||||
connection.OnConnectionClosed();
|
connection.OnConnectionClosed();
|
||||||
|
|
||||||
|
|
@ -99,8 +99,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task AsTask(CancellationToken token)
|
private static Task CancellationTokenAsTask(CancellationToken token)
|
||||||
{
|
{
|
||||||
|
if (token.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transports already dispatch prior to tripping ConnectionClosed
|
||||||
|
// since application code can register to this token.
|
||||||
var tcs = new TaskCompletionSource<object>();
|
var tcs = new TaskCompletionSource<object>();
|
||||||
token.Register(() => tcs.SetResult(null));
|
token.Register(() => tcs.SetResult(null));
|
||||||
return tcs.Task;
|
return tcs.Task;
|
||||||
|
|
|
||||||
|
|
@ -55,14 +55,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal
|
||||||
|
|
||||||
public CancellationToken ConnectionClosed { get; set; }
|
public CancellationToken ConnectionClosed { get; set; }
|
||||||
|
|
||||||
// DO NOT remove this override to ConnectionContext.Abort(). Doing so would cause
|
// DO NOT remove this override to ConnectionContext.Abort. Doing so would cause
|
||||||
// any TransportConnection that does not override Abort() or calls base.Abort()
|
// any TransportConnection that does not override Abort or calls base.Abort
|
||||||
// to stack overflow when IConnectionLifetimeFeature.Abort() is called.
|
// to stack overflow when IConnectionLifetimeFeature.Abort() is called.
|
||||||
|
// That said, all derived types should override this method should override
|
||||||
|
// this implementation of Abort because canceling pending output reads is not
|
||||||
|
// sufficient to abort the connection if there is backpressure.
|
||||||
public override void Abort(ConnectionAbortedException abortReason)
|
public override void Abort(ConnectionAbortedException abortReason)
|
||||||
{
|
{
|
||||||
AbortCore(abortReason);
|
Output.CancelPendingRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void AbortCore(ConnectionAbortedException abortReason);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void AbortCore(ConnectionAbortedException abortReason)
|
public override void Abort(ConnectionAbortedException abortReason)
|
||||||
{
|
{
|
||||||
_abortReason = abortReason;
|
_abortReason = abortReason;
|
||||||
Output.CancelPendingRead();
|
Output.CancelPendingRead();
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void AbortCore(ConnectionAbortedException abortReason)
|
public override void Abort(ConnectionAbortedException abortReason)
|
||||||
{
|
{
|
||||||
_abortReason = abortReason;
|
_abortReason = abortReason;
|
||||||
Output.CancelPendingRead();
|
Output.CancelPendingRead();
|
||||||
|
|
|
||||||
|
|
@ -2459,7 +2459,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
||||||
await context.Response.Body.WriteAsync(scratchBuffer, 0, scratchBuffer.Length);
|
await context.Response.Body.WriteAsync(scratchBuffer, 0, scratchBuffer.Length);
|
||||||
await Task.Delay(10);
|
await Task.Delay(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
appCompletedTcs.SetResult(null);
|
appCompletedTcs.SetResult(null);
|
||||||
}, new TestServiceContext(LoggerFactory), listenOptions))
|
}, new TestServiceContext(LoggerFactory), listenOptions))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue