From 20ad884dbeb8851aa8b84cd2192f925bdd0212c4 Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 1 Apr 2016 11:06:48 +0900 Subject: [PATCH] [Fix] Move it out As a preventive move. See: issue #235 --- websocket-sharp/Net/HttpListener.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/websocket-sharp/Net/HttpListener.cs b/websocket-sharp/Net/HttpListener.cs index 3ab4def4..822b9d01 100644 --- a/websocket-sharp/Net/HttpListener.cs +++ b/websocket-sharp/Net/HttpListener.cs @@ -433,18 +433,20 @@ namespace WebSocketSharp.Net private void cleanupContextRegistry () { + HttpListenerContext[] ctxs = null; lock (_ctxRegistrySync) { if (_ctxRegistry.Count == 0) return; // Need to copy this since closing will call the UnregisterContext method. var keys = _ctxRegistry.Keys; - var ctxs = new HttpListenerContext[keys.Count]; + ctxs = new HttpListenerContext[keys.Count]; keys.CopyTo (ctxs, 0); _ctxRegistry.Clear (); - for (var i = ctxs.Length - 1; i >= 0; i--) - ctxs[i].Connection.Close (true); } + + for (var i = ctxs.Length - 1; i >= 0; i--) + ctxs[i].Connection.Close (true); } private void cleanupWaitQueue ()