Add a mutex around groups of send() calls in NetworkClient.cpp to fix corrupt packets due to race conditions. If two network RGBControllers try to send a packet with data at the same time, a race condition could cause data from another thread to send in between the header and data for the active thread, corrupting the data stream.

This commit is contained in:
Adam Honse 2024-07-27 16:23:54 -05:00
parent 44268596b3
commit 99c1aa0c26
2 changed files with 33 additions and 0 deletions

View file

@ -102,6 +102,7 @@ private:
unsigned int server_protocol_version;
bool server_protocol_version_received;
bool change_in_progress;
std::mutex send_in_progress;
std::thread * ConnectionThread;
std::thread * ListenThread;