From e5ff33eda2a581cd976dfca44fe38b19b1ec5821 Mon Sep 17 00:00:00 2001 From: Stephen Halter Date: Mon, 9 Nov 2015 19:31:46 -0800 Subject: [PATCH] Remove UvAsyncHandle.DangerousClose - This should stop the AVs we've been seeing in some of our test runs --- .../Infrastructure/KestrelThread.cs | 25 +++++++++++++++---- .../Networking/UvAsyncHandle.cs | 6 ----- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/KestrelThread.cs b/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/KestrelThread.cs index 85a4b50621..a8608de70f 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/KestrelThread.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/KestrelThread.cs @@ -67,10 +67,24 @@ namespace Microsoft.AspNet.Server.Kestrel Post(OnStop, null); if (!_thread.Join((int)timeout.TotalMilliseconds)) { - Post(OnStopRude, null); - if (!_thread.Join((int)timeout.TotalMilliseconds)) + try { - Post(OnStopImmediate, null); + Post(OnStopRude, null); + if (!_thread.Join((int)timeout.TotalMilliseconds)) + { + Post(OnStopImmediate, null); + if (!_thread.Join((int)timeout.TotalMilliseconds)) + { +#if NET451 + _thread.Abort(); +#endif + } + } + } + catch (ObjectDisposedException) + { + // REVIEW: Should we log something here? + // Until we rework this logic, ODEs are bound to happen sometimes. if (!_thread.Join((int)timeout.TotalMilliseconds)) { #if NET451 @@ -79,6 +93,7 @@ namespace Microsoft.AspNet.Server.Kestrel } } } + if (_closeError != null) { _closeError.Throw(); @@ -217,7 +232,7 @@ namespace Microsoft.AspNet.Server.Kestrel // run the loop one more time to delete the open handles _post.Reference(); - _post.DangerousClose(); + _post.Dispose(); _engine.Libuv.walk( _loop, @@ -231,7 +246,7 @@ namespace Microsoft.AspNet.Server.Kestrel }, IntPtr.Zero); - // Ensure the "DangerousClose" operation completes in the event loop. + // Ensure the Dispose operations complete in the event loop. var ran2 = _loop.Run(); _loop.Dispose(); diff --git a/src/Microsoft.AspNet.Server.Kestrel/Networking/UvAsyncHandle.cs b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvAsyncHandle.cs index 9b4ecb60f8..03c6ece9e5 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Networking/UvAsyncHandle.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvAsyncHandle.cs @@ -26,12 +26,6 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking _uv.async_init(loop, this, _uv_async_cb); } - public void DangerousClose() - { - Dispose(); - ReleaseHandle(); - } - public void Send() { _uv.async_send(this);