[Modify] Lock it within the method

This commit is contained in:
sta 2016-04-03 16:33:18 +09:00
parent 40b74422a2
commit 655acc6528

View File

@ -469,9 +469,9 @@ namespace WebSocketSharp.Net
cleanup (force);
}
// Must be called with a lock on _ctxQueue.
private HttpListenerContext getContextFromQueue ()
{
lock (_ctxQueueSync) {
if (_ctxQueue.Count == 0)
return null;
@ -480,6 +480,7 @@ namespace WebSocketSharp.Net
return ctx;
}
}
private void sendServiceUnavailable ()
{
@ -561,13 +562,11 @@ namespace WebSocketSharp.Net
// Lock _waitQueue early to avoid race conditions.
lock (_waitQueueSync) {
lock (_ctxQueueSync) {
var ctx = getContextFromQueue ();
if (ctx != null) {
asyncResult.Complete (ctx, true);
return asyncResult;
}
}
_waitQueue.Add (asyncResult);
}