diff --git a/src/eckit/net/TCPServer.cc b/src/eckit/net/TCPServer.cc index 425709dbe..5f264047d 100644 --- a/src/eckit/net/TCPServer.cc +++ b/src/eckit/net/TCPServer.cc @@ -36,6 +36,8 @@ TCPServer::~TCPServer() { TCPSocket& TCPServer::accept(const std::string& message, int timeout, bool* connected) { + std::lock_guard lock(acceptMutex_); + bind(); sockaddr_in from; diff --git a/src/eckit/net/TCPServer.h b/src/eckit/net/TCPServer.h index e29f6e861..0d0c1e827 100644 --- a/src/eckit/net/TCPServer.h +++ b/src/eckit/net/TCPServer.h @@ -58,6 +58,7 @@ class TCPServer : public TCPSocket, private NonCopyable { private: // members bool closeExec_; Mutex mutex_; + std::recursive_mutex acceptMutex_; }; //----------------------------------------------------------------------------------------------------------------------