From 858e5ab3a2ef74893703b9dac2ff66cac2729c5a Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Sun, 22 Nov 2015 16:11:41 +0000 Subject: [PATCH] Moar stopping power, Timeout is total timout --- .../Infrastructure/KestrelThread.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/KestrelThread.cs b/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/KestrelThread.cs index 93c30a55dd..a288ef49ac 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/KestrelThread.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/KestrelThread.cs @@ -64,16 +64,18 @@ namespace Microsoft.AspNet.Server.Kestrel return; } + var stepTimeout = (int)(timeout.TotalMilliseconds / 3); + Post(t => t.OnStop()); - if (!_thread.Join((int)timeout.TotalMilliseconds)) + if (!_thread.Join(stepTimeout)) { try { Post(t => t.OnStopRude()); - if (!_thread.Join((int)timeout.TotalMilliseconds)) + if (!_thread.Join(stepTimeout)) { Post(t => t.OnStopImmediate()); - if (!_thread.Join((int)timeout.TotalMilliseconds)) + if (!_thread.Join(stepTimeout)) { #if NET451 _thread.Abort(); @@ -85,7 +87,7 @@ namespace Microsoft.AspNet.Server.Kestrel { // REVIEW: Should we log something here? // Until we rework this logic, ODEs are bound to happen sometimes. - if (!_thread.Join((int)timeout.TotalMilliseconds)) + if (!_thread.Join(stepTimeout)) { #if NET451 _thread.Abort();