From 488c25642cda7fb341b2837bf6c64b586aecad63 Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 15 Feb 2014 04:54:36 +0900 Subject: [PATCH] Fix for issue #30 --- websocket-sharp/WebSocket.cs | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index bc80eea6..0479bcd5 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -1544,25 +1544,21 @@ namespace WebSocketSharp internal void Send (Opcode opcode, Stream stream, Dictionary cache) { lock (_forSend) { - lock (_forConn) { - if (_readyState != WebSocketState.OPEN) - return; - - try { - Stream cached; - if (!cache.TryGetValue (_compression, out cached)) { - cached = stream.Compress (_compression); - cache.Add (_compression, cached); - } - else - cached.Position = 0; + try { + Stream cached; + if (!cache.TryGetValue (_compression, out cached)) { + cached = stream.Compress (_compression); + cache.Add (_compression, cached); + } + else + cached.Position = 0; + if (_readyState == WebSocketState.OPEN) sendFragmented (opcode, cached, Mask.UNMASK, _compression != CompressionMethod.NONE); - } - catch (Exception ex) { - _logger.Fatal (ex.ToString ()); - error ("An exception has occurred while sending a data."); - } + } + catch (Exception ex) { + _logger.Fatal (ex.ToString ()); + error ("An exception has occurred while sending a data."); } } }