Wait for graceful shutdown now that it usually works
- Unreference the async handle to allow the loop to stop without walking first - Wait before walking open handles to allow earlier uv_close calls to complete
This commit is contained in:
parent
9a79ef5213
commit
dc12f3150e
|
|
@ -105,34 +105,40 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var stepTimeout = (int)(timeout.TotalMilliseconds / 3);
|
||||||
|
|
||||||
if (_thread.IsAlive)
|
if (_thread.IsAlive)
|
||||||
{
|
{
|
||||||
// These operations need to run on the libuv thread so it only makes
|
// These operations need to run on the libuv thread so it only makes
|
||||||
// sense to attempt execution if it's still running
|
// sense to attempt execution if it's still running
|
||||||
DisposeConnections();
|
DisposeConnections();
|
||||||
|
|
||||||
var stepTimeout = (int)(timeout.TotalMilliseconds / 2);
|
Post(t => t.AllowStop());
|
||||||
try
|
if (!_thread.Join(stepTimeout))
|
||||||
{
|
{
|
||||||
Post(t => t.OnStopRude());
|
|
||||||
if (!_thread.Join(stepTimeout))
|
try
|
||||||
{
|
{
|
||||||
Post(t => t.OnStopImmediate());
|
Post(t => t.OnStopRude());
|
||||||
|
if (!_thread.Join(stepTimeout))
|
||||||
|
{
|
||||||
|
Post(t => t.OnStopImmediate());
|
||||||
|
if (!_thread.Join(stepTimeout))
|
||||||
|
{
|
||||||
|
_log.LogError(0, null, "KestrelThread.Stop failed to terminate libuv thread.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (ObjectDisposedException)
|
||||||
|
{
|
||||||
|
// REVIEW: Should we log something here?
|
||||||
|
// Until we rework this logic, ODEs are bound to happen sometimes.
|
||||||
if (!_thread.Join(stepTimeout))
|
if (!_thread.Join(stepTimeout))
|
||||||
{
|
{
|
||||||
_log.LogError(0, null, "KestrelThread.Stop failed to terminate libuv thread.");
|
_log.LogError(0, null, "KestrelThread.Stop failed to terminate libuv thread.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ObjectDisposedException)
|
|
||||||
{
|
|
||||||
// REVIEW: Should we log something here?
|
|
||||||
// Until we rework this logic, ODEs are bound to happen sometimes.
|
|
||||||
if (!_thread.Join(stepTimeout))
|
|
||||||
{
|
|
||||||
_log.LogError(0, null, "KestrelThread.Stop failed to terminate libuv thread.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_closeError != null)
|
if (_closeError != null)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue