From feb9d1281ea88dbaebabd10c0974ee9029b3aa60 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Fri, 21 Apr 2017 13:12:37 -0700 Subject: [PATCH] Tweak libuv shutdown sequence (#1735) * Tweak libuv shutdown sequence - Increase timeouts for thread and listener shutdowns - Remove post.Unreference call from AllowStopRude --- .../Internal/LibuvThread.cs | 4 ---- .../LibuvTransport.cs | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv/Internal/LibuvThread.cs b/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv/Internal/LibuvThread.cs index db70ba2c1a..e816d2630b 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv/Internal/LibuvThread.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv/Internal/LibuvThread.cs @@ -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() diff --git a/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv/LibuvTransport.cs b/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv/LibuvTransport.cs index bf23beeb0e..502c8bddfc 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv/LibuvTransport.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv/LibuvTransport.cs @@ -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"); }