Fixes for memory issues detected by valgrind

This commit is contained in:
Térence Clastres 2020-08-12 20:29:39 +02:00 committed by Adam Honse
parent ff07a488a2
commit 53379c5482
17 changed files with 74 additions and 27 deletions

View file

@ -31,6 +31,7 @@ NetworkClient::NetworkClient(std::vector<RGBController *>& control) : controller
{
strcpy(port_ip, "127.0.0.1");
port_num = OPENRGB_SDK_PORT;
client_sock = -1;
server_connected = false;
server_controller_count = 0;
@ -38,6 +39,11 @@ NetworkClient::NetworkClient(std::vector<RGBController *>& control) : controller
ConnectionThread = NULL;
}
NetworkClient::~NetworkClient()
{
delete ConnectionThread;
}
void NetworkClient::ClientInfoChanged()
{
ClientInfoChangeMutex.lock();
@ -129,8 +135,12 @@ void NetworkClient::StopClient()
server_connected = false;
client_active = false;
shutdown(client_sock, SD_RECEIVE);
closesocket(client_sock);
if (server_connected)
{
shutdown(client_sock, SD_RECEIVE);
closesocket(client_sock);
}
if(ListenThread)
ListenThread->join();
ConnectionThread->join();