From adc03104916968ef7958fc051f0ddd92f885118c Mon Sep 17 00:00:00 2001 From: Stephen Halter Date: Fri, 12 Jun 2015 12:49:52 -0700 Subject: [PATCH] Ensure all handles still get released after graceful shutdown --- .../Infrastructure/KestrelThread.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/KestrelThread.cs b/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/KestrelThread.cs index e24b4e1f12..821a8216da 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/KestrelThread.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/KestrelThread.cs @@ -153,6 +153,18 @@ namespace Microsoft.AspNet.Server.Kestrel _post.Reference(); _post.DangerousClose(); + _engine.Libuv.walk( + _loop, + (ptr, arg) => + { + var handle = UvMemory.FromIntPtr(ptr); + if (handle != _post) + { + handle.Dispose(); + } + }, + IntPtr.Zero); + // Ensure the "DangerousClose" operation completes in the event loop. var ran2 = _loop.Run();