WSServer(stop): wait for all connections to close

This commit is contained in:
Stéphane Lepin 2021-01-20 00:08:24 +01:00
parent 5fd95ce374
commit bc3b09dce4

View File

@ -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");