[Modify] Polish it

This commit is contained in:
sta 2021-04-21 19:46:58 +09:00
parent 928fd0755f
commit dc420c7b7e

View File

@ -433,22 +433,18 @@ namespace WebSocketSharp.Net
private void cleanupContextRegistry () private void cleanupContextRegistry ()
{ {
HttpListenerContext[] ctxs = null;
lock (_contextRegistrySync) {
var cnt = _contextRegistry.Count; var cnt = _contextRegistry.Count;
if (cnt == 0) if (cnt == 0)
return; return;
ctxs = new HttpListenerContext[cnt]; var ctxs = new HttpListenerContext[cnt];
_contextRegistry.CopyTo (ctxs, 0); _contextRegistry.CopyTo (ctxs, 0);
_contextRegistry.Clear (); _contextRegistry.Clear ();
}
for (var i = ctxs.Length - 1; i >= 0; i--) foreach (var ctx in ctxs)
ctxs[i].Connection.Close (true); ctx.Connection.Close (true);
} }
private void cleanupWaitQueue (Exception exception) private void cleanupWaitQueue (Exception exception)