[Fix] Check if can register a context
This commit is contained in:
parent
c9511823b8
commit
fdf1a18809
@ -303,7 +303,12 @@ namespace WebSocketSharp.Net
|
|||||||
}
|
}
|
||||||
|
|
||||||
conn._contextBound = true;
|
conn._contextBound = true;
|
||||||
lsnr.RegisterContext (conn._context);
|
if (!lsnr.RegisterContext (conn._context)) {
|
||||||
|
conn._contextBound = false;
|
||||||
|
conn.close ();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -581,25 +581,33 @@ namespace WebSocketSharp.Net
|
|||||||
throw new ObjectDisposedException (GetType ().ToString ());
|
throw new ObjectDisposedException (GetType ().ToString ());
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void RegisterContext (HttpListenerContext context)
|
internal bool RegisterContext (HttpListenerContext context)
|
||||||
{
|
{
|
||||||
lock (_ctxRegistrySync)
|
if (!_listening)
|
||||||
_ctxRegistry[context] = context;
|
return false;
|
||||||
|
|
||||||
HttpListenerAsyncResult ares = null;
|
HttpListenerAsyncResult ares = null;
|
||||||
lock (_waitQueueSync) {
|
lock (_ctxRegistrySync) {
|
||||||
if (_waitQueue.Count == 0) {
|
if (!_listening)
|
||||||
lock (_ctxQueueSync)
|
return false;
|
||||||
_ctxQueue.Add (context);
|
|
||||||
}
|
_ctxRegistry[context] = context;
|
||||||
else {
|
lock (_waitQueueSync) {
|
||||||
ares = _waitQueue[0];
|
if (_waitQueue.Count == 0) {
|
||||||
_waitQueue.RemoveAt (0);
|
lock (_ctxQueueSync)
|
||||||
|
_ctxQueue.Add (context);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ares = _waitQueue[0];
|
||||||
|
_waitQueue.RemoveAt (0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ares != null)
|
if (ares != null)
|
||||||
ares.Complete (context);
|
ares.Complete (context);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void RemoveConnection (HttpConnection connection)
|
internal void RemoveConnection (HttpConnection connection)
|
||||||
|
Loading…
Reference in New Issue
Block a user