[Modify] Lock it within the method
This commit is contained in:
parent
40b74422a2
commit
655acc6528
@ -469,9 +469,9 @@ namespace WebSocketSharp.Net
|
|||||||
cleanup (force);
|
cleanup (force);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Must be called with a lock on _ctxQueue.
|
|
||||||
private HttpListenerContext getContextFromQueue ()
|
private HttpListenerContext getContextFromQueue ()
|
||||||
{
|
{
|
||||||
|
lock (_ctxQueueSync) {
|
||||||
if (_ctxQueue.Count == 0)
|
if (_ctxQueue.Count == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@ -480,6 +480,7 @@ namespace WebSocketSharp.Net
|
|||||||
|
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void sendServiceUnavailable ()
|
private void sendServiceUnavailable ()
|
||||||
{
|
{
|
||||||
@ -561,13 +562,11 @@ namespace WebSocketSharp.Net
|
|||||||
|
|
||||||
// Lock _waitQueue early to avoid race conditions.
|
// Lock _waitQueue early to avoid race conditions.
|
||||||
lock (_waitQueueSync) {
|
lock (_waitQueueSync) {
|
||||||
lock (_ctxQueueSync) {
|
|
||||||
var ctx = getContextFromQueue ();
|
var ctx = getContextFromQueue ();
|
||||||
if (ctx != null) {
|
if (ctx != null) {
|
||||||
asyncResult.Complete (ctx, true);
|
asyncResult.Complete (ctx, true);
|
||||||
return asyncResult;
|
return asyncResult;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_waitQueue.Add (asyncResult);
|
_waitQueue.Add (asyncResult);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user