From bc3b09dce4bf25eb99007dabff078deb2f5b027d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lepin?= Date: Wed, 20 Jan 2021 00:08:24 +0100 Subject: [PATCH] WSServer(stop): wait for all connections to close --- src/WSServer.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/WSServer.cpp b/src/WSServer.cpp index add0e1e1..33639dd1 100644 --- a/src/WSServer.cpp +++ b/src/WSServer.cpp @@ -121,13 +121,11 @@ void WSServer::stop() for (connection_hdl hdl : _connections) { _server.close(hdl, websocketpp::close::status::going_away, "Server stopping"); } - _connections.clear(); - _connectionProperties.clear(); _threadPool.waitForDone(); - while (!_server.stopped()) { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); + while (_connections.size() > 0) { + std::this_thread::sleep_for(std::chrono::milliseconds(10)); } blog(LOG_INFO, "server stopped successfully");