[Modify] Polish it

This commit is contained in:
sta 2016-04-16 15:21:46 +09:00
parent 7e80355694
commit e90c153391

View File

@ -566,23 +566,21 @@ namespace WebSocketSharp.Net
internal HttpListenerAsyncResult BeginGetContext (HttpListenerAsyncResult asyncResult)
{
// Lock _ctxRegistrySync early to avoid race conditions.
lock (_ctxRegistrySync) {
if (!_listening)
throw new HttpListenerException (995);
lock (_waitQueueSync) {
var ctx = getContextFromQueue ();
if (ctx != null) {
asyncResult.Complete (ctx, true);
return asyncResult;
}
_waitQueue.Add (asyncResult);
var ctx = getContextFromQueue ();
if (ctx == null) {
lock (_waitQueueSync)
_waitQueue.Add (asyncResult);
}
else {
asyncResult.Complete (ctx, true);
}
}
return asyncResult;
return asyncResult;
}
}
internal void CheckDisposed ()