diff --git a/ixwebsocket/IXWebSocketTransport.cpp b/ixwebsocket/IXWebSocketTransport.cpp index 45a1f93d..94c02591 100644 --- a/ixwebsocket/IXWebSocketTransport.cpp +++ b/ixwebsocket/IXWebSocketTransport.cpp @@ -152,7 +152,7 @@ namespace ix std::string errorMsg; { bool tls = protocol == "wss"; - std::lock_guard lock(_socketMutex); + std::lock_guard lock(_socketMutex); _socket = createSocket(tls, errorMsg); if (!_socket) @@ -184,7 +184,7 @@ namespace ix std::string errorMsg; { - std::lock_guard lock(_socketMutex); + std::lock_guard lock(_socketMutex); _socket = createSocket(fd, errorMsg); if (!_socket) @@ -956,7 +956,7 @@ namespace ix ssize_t WebSocketTransport::send() { - std::lock_guard lock(_socketMutex); + std::lock_guard lock(_socketMutex); return _socket->send((char*)&_txbuf[0], _txbuf.size()); } @@ -1010,7 +1010,7 @@ namespace ix void WebSocketTransport::closeSocket() { - std::lock_guard lock(_socketMutex); + std::lock_guard lock(_socketMutex); _socket->close(); } diff --git a/ixwebsocket/IXWebSocketTransport.h b/ixwebsocket/IXWebSocketTransport.h index 83f168b6..bae374ee 100644 --- a/ixwebsocket/IXWebSocketTransport.h +++ b/ixwebsocket/IXWebSocketTransport.h @@ -154,7 +154,7 @@ namespace ix // Underlying TCP socket std::shared_ptr _socket; - std::mutex _socketMutex; + std::recursive_mutex _socketMutex; // Hold the state of the connection (OPEN, CLOSED, etc...) std::atomic _readyState; diff --git a/test/IXWebSocketTestConnectionDisconnection.cpp b/test/IXWebSocketTestConnectionDisconnection.cpp index d06c30c2..dd4588e1 100644 --- a/test/IXWebSocketTestConnectionDisconnection.cpp +++ b/test/IXWebSocketTestConnectionDisconnection.cpp @@ -140,7 +140,7 @@ TEST_CASE("websocket_connections", "[websocket]") // This test breaks on travis CI - Ubuntu Xenial + gcc + tsan // We should fix this. - /*SECTION("Try to connect and disconnect with different timing, from not enough time to successfull connect") + SECTION("Try to connect and disconnect with different timing, from not enough time to successfull connect") { IXWebSocketTestConnectionDisconnection test; for (int i = 0; i < 20; ++i) @@ -150,5 +150,5 @@ TEST_CASE("websocket_connections", "[websocket]") ix::msleep(i*50); test.stop(); } - }*/ + } }