Fix deadlock when connection is simultaneously aborted and ended (#684).
This commit is contained in:
parent
7c67366e84
commit
8e24c3a708
|
|
@ -152,23 +152,24 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
|
||||||
|
|
||||||
public virtual void Abort()
|
public virtual void Abort()
|
||||||
{
|
{
|
||||||
lock (_stateLock)
|
// Frame.Abort calls user code while this method is always
|
||||||
|
// called from a libuv thread.
|
||||||
|
System.Threading.ThreadPool.QueueUserWorkItem(state =>
|
||||||
{
|
{
|
||||||
if (_connectionState == ConnectionState.CreatingFrame)
|
var connection = (Connection)state;
|
||||||
|
|
||||||
|
lock (connection._stateLock)
|
||||||
{
|
{
|
||||||
_connectionState = ConnectionState.ToDisconnect;
|
if (connection._connectionState == ConnectionState.CreatingFrame)
|
||||||
}
|
{
|
||||||
else
|
connection._connectionState = ConnectionState.ToDisconnect;
|
||||||
{
|
}
|
||||||
// Frame.Abort calls user code while this method is always
|
else
|
||||||
// called from a libuv thread.
|
|
||||||
System.Threading.ThreadPool.QueueUserWorkItem(state =>
|
|
||||||
{
|
{
|
||||||
var connection = (Connection)state;
|
|
||||||
connection._frame.Abort();
|
connection._frame.Abort();
|
||||||
}, this);
|
}
|
||||||
}
|
}
|
||||||
}
|
}, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called on Libuv thread
|
// Called on Libuv thread
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue