[Modify] Polish it
This commit is contained in:
parent
7e80355694
commit
e90c153391
@ -566,24 +566,22 @@ namespace WebSocketSharp.Net
|
|||||||
|
|
||||||
internal HttpListenerAsyncResult BeginGetContext (HttpListenerAsyncResult asyncResult)
|
internal HttpListenerAsyncResult BeginGetContext (HttpListenerAsyncResult asyncResult)
|
||||||
{
|
{
|
||||||
// Lock _ctxRegistrySync early to avoid race conditions.
|
|
||||||
lock (_ctxRegistrySync) {
|
lock (_ctxRegistrySync) {
|
||||||
if (!_listening)
|
if (!_listening)
|
||||||
throw new HttpListenerException (995);
|
throw new HttpListenerException (995);
|
||||||
|
|
||||||
lock (_waitQueueSync) {
|
|
||||||
var ctx = getContextFromQueue ();
|
var ctx = getContextFromQueue ();
|
||||||
if (ctx != null) {
|
if (ctx == null) {
|
||||||
asyncResult.Complete (ctx, true);
|
lock (_waitQueueSync)
|
||||||
return asyncResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
_waitQueue.Add (asyncResult);
|
_waitQueue.Add (asyncResult);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
asyncResult.Complete (ctx, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return asyncResult;
|
return asyncResult;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal void CheckDisposed ()
|
internal void CheckDisposed ()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user