(socket server) wait for all connections threads to be terminated before exiting stop method
This commit is contained in:
parent
9131cb4790
commit
662f66e501
@ -137,8 +137,16 @@ namespace ix
|
|||||||
|
|
||||||
void SocketServer::stop()
|
void SocketServer::stop()
|
||||||
{
|
{
|
||||||
closeTerminatedThreads();
|
while (true)
|
||||||
assert(_connectionsThreads.empty());
|
{
|
||||||
|
closeTerminatedThreads();
|
||||||
|
if (_connectionsThreads.empty()) break;
|
||||||
|
|
||||||
|
// wait 10ms and try again later.
|
||||||
|
// we could have a timeout, but if we exit of here
|
||||||
|
// we leaked threads, it is quite bad.
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||||
|
}
|
||||||
|
|
||||||
if (!_thread.joinable()) return; // nothing to do
|
if (!_thread.joinable()) return; // nothing to do
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user