better server termination / another try at preventing thread join failures
This commit is contained in:
parent
f1b3ecc738
commit
f563d14134
@ -135,6 +135,11 @@ namespace ix
|
|||||||
_conditionVariable.wait(lock);
|
_conditionVariable.wait(lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SocketServer::stopAcceptingConnections()
|
||||||
|
{
|
||||||
|
_stop = true;
|
||||||
|
}
|
||||||
|
|
||||||
void SocketServer::stop()
|
void SocketServer::stop()
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
@ -270,6 +275,8 @@ namespace ix
|
|||||||
connectionState = _connectionStateFactory();
|
connectionState = _connectionStateFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_stop) return;
|
||||||
|
|
||||||
// Launch the handleConnection work asynchronously in its own thread.
|
// Launch the handleConnection work asynchronously in its own thread.
|
||||||
_connectionsThreads.push_back(std::make_pair(
|
_connectionsThreads.push_back(std::make_pair(
|
||||||
connectionState,
|
connectionState,
|
||||||
|
@ -57,6 +57,8 @@ namespace ix
|
|||||||
void logError(const std::string& str);
|
void logError(const std::string& str);
|
||||||
void logInfo(const std::string& str);
|
void logInfo(const std::string& str);
|
||||||
|
|
||||||
|
void stopAcceptingConnections();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Member variables
|
// Member variables
|
||||||
int _port;
|
int _port;
|
||||||
|
@ -37,6 +37,8 @@ namespace ix
|
|||||||
|
|
||||||
void WebSocketServer::stop()
|
void WebSocketServer::stop()
|
||||||
{
|
{
|
||||||
|
stopAcceptingConnections();
|
||||||
|
|
||||||
auto clients = getClients();
|
auto clients = getClients();
|
||||||
for (auto client : clients)
|
for (auto client : clients)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user