Improving NetworkServer's memory management (#373)

This patch resolves several bugs:

* NetworkServer would allocate various instances of `NetworkClientInfo`.
  This is patched by deallocating the NetworkClientInfo when it's
  listening thread ends in the `listen_done` section.

* Memory would be allocated for threads that wouldn't be freed. This
  is resolved by detaching from the threads, so they no longer need to
  be joined to be freed, and then freeing the memory as they finish.

* Thread-Safety issues involving `ServerClients` would result in stray
  `NetworkClientInfo`'s not being removed from the list in certain
  situations. This is resolved by used a mutex to lock access to this
  from different threads.
This commit is contained in:
B Horn 2020-07-09 23:15:36 +01:00 committed by Adam Honse
parent 263561868c
commit 47baeb6b6b
2 changed files with 38 additions and 12 deletions

View file

@ -59,6 +59,7 @@ protected:
std::vector<RGBController *>& controllers;
std::mutex ServerClientsMutex;
std::vector<NetworkClientInfo *> ServerClients;
std::thread * ConnectionThread;