network_utils: fix TSAN detected race

This commit is contained in:
Andre Puschmann 2021-06-14 12:51:30 +02:00
parent 3173dedf0a
commit bbcaa49429
2 changed files with 2 additions and 2 deletions

View File

@ -154,7 +154,7 @@ private:
// state
std::mutex socket_mutex;
std::map<int, recv_callback_t> active_sockets;
bool running = false;
std::atomic<bool> running = {false};
int pipefd[2] = {-1, -1};
std::vector<int> rem_fd_tmp_list;
std::condition_variable rem_cvar;

View File

@ -459,7 +459,7 @@ void socket_manager::run_thread()
FD_SET(pipefd[0], &total_fd_set);
max_fd = std::max(pipefd[0], max_fd);
while (running) {
while (running.load(std::memory_order_relaxed)) {
memcpy(&read_fd_set, &total_fd_set, sizeof(total_fd_set));
int n = select(max_fd + 1, &read_fd_set, nullptr, nullptr, nullptr);