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:
Stephen Halter 2016-07-19 16:49:19 -07:00
parent 9a79ef5213
commit dc12f3150e
1 changed files with 20 additions and 14 deletions

View File

@ -105,13 +105,18 @@ 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());
if (!_thread.Join(stepTimeout))
{
try try
{ {
Post(t => t.OnStopRude()); Post(t => t.OnStopRude());
@ -134,6 +139,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal
} }
} }
} }
}
if (_closeError != null) if (_closeError != null)
{ {