Modified closing

This commit is contained in:
sta 2013-09-07 17:29:15 +09:00
parent 80afaef7c9
commit a01e7cb24d

View File

@ -535,6 +535,7 @@ namespace WebSocketSharp
{ {
_logger.Debug ("Is this thread background?: " + Thread.CurrentThread.IsBackground); _logger.Debug ("Is this thread background?: " + Thread.CurrentThread.IsBackground);
var sent = false;
CloseEventArgs args = null; CloseEventArgs args = null;
lock (_forClose) lock (_forClose)
{ {
@ -556,17 +557,16 @@ namespace WebSocketSharp
else else
{ {
if (!data.ContainsReservedCloseStatusCode) if (!data.ContainsReservedCloseStatusCode)
args.WasClean = send (createControlFrame (Opcode.CLOSE, data, _client)); sent = send (createControlFrame (Opcode.CLOSE, data, _client));
} }
} }
if (!Thread.CurrentThread.IsBackground && var received = Thread.CurrentThread.IsBackground ||
_exitReceiving != null && (_exitReceiving != null && _exitReceiving.WaitOne (5 * 1000));
!_exitReceiving.WaitOne (5 * 1000))
args.WasClean = false;
if (!closeResources ()) var released = closeResources ();
args.WasClean = false; args.WasClean = sent && received && released;
_logger.Debug ("Was clean?: " + args.WasClean);
_readyState = WebSocketState.CLOSED; _readyState = WebSocketState.CLOSED;
OnClose.Emit (this, args); OnClose.Emit (this, args);