Tweak libuv shutdown sequence (#1735)

* Tweak libuv shutdown sequence
- Increase timeouts for thread and listener shutdowns
- Remove post.Unreference call from AllowStopRude
This commit is contained in:
David Fowler 2017-04-21 13:12:37 -07:00 committed by GitHub
parent dcea15dba7
commit feb9d1281e
2 changed files with 2 additions and 6 deletions

View File

@ -5,7 +5,6 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
@ -165,9 +164,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
handle?.Dispose();
}
});
// uv_unref is idempotent so it's OK to call this here and in AllowStop.
_post.Unreference();
}
private void OnStopImmediate()

View File

@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv
{
try
{
await Task.WhenAll(Threads.Select(thread => thread.StopAsync(TimeSpan.FromSeconds(2.5))).ToArray())
await Task.WhenAll(Threads.Select(thread => thread.StopAsync(TimeSpan.FromSeconds(5))).ToArray())
.ConfigureAwait(false);
}
catch (AggregateException aggEx)
@ -123,7 +123,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv
{
var disposeTasks = _listeners.Select(listener => listener.DisposeAsync()).ToArray();
if (!await WaitAsync(Task.WhenAll(disposeTasks), TimeSpan.FromSeconds(2.5)).ConfigureAwait(false))
if (!await WaitAsync(Task.WhenAll(disposeTasks), TimeSpan.FromSeconds(5)).ConfigureAwait(false))
{
Log.LogError(0, null, "Disposing listeners failed");
}