Tiny threads fixes & a little bit of safety

This commit is contained in:
k1-801 2020-11-15 16:00:59 +04:00 committed by Adam Honse
parent 9a53709db0
commit dde857dfb4
18 changed files with 85 additions and 154 deletions

View file

@ -37,6 +37,12 @@ NetworkServer::NetworkServer(std::vector<RGBController *>& control) : controller
{
port_num = OPENRGB_SDK_PORT;
server_online = false;
ConnectionThread = nullptr;
}
NetworkServer::~NetworkServer()
{
StopServer();
}
void NetworkServer::ClientInfoChanged()
@ -214,6 +220,13 @@ void NetworkServer::StopServer()
ServerClients.clear();
ServerClientsMutex.unlock();
if(ConnectionThread)
{
ConnectionThread->join();
delete ConnectionThread;
ConnectionThread = nullptr;
}
/*-------------------------------------------------*\
| Client info has changed, call the callbacks |
\*-------------------------------------------------*/