File tree Expand file tree Collapse file tree 2 files changed +4
-0
lines changed Expand file tree Collapse file tree 2 files changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -486,6 +486,8 @@ class TimersManager
486486 std::thread timers_thread_;
487487 // Protects access to timers
488488 std::mutex timers_mutex_;
489+ // Protects access to stop()
490+ std::mutex stop_mutex_;
489491 // Notifies the timers thread whenever timers are added/removed
490492 std::condition_variable timers_cv_;
491493 // Flag used as predicate by timers_cv_ that denotes one or more timers being added/removed
Original file line number Diff line number Diff line change @@ -59,6 +59,8 @@ void TimersManager::start()
5959
6060void TimersManager::stop ()
6161{
62+ // Lock stop() function to prevent race condition in destructor
63+ std::unique_lock<std::mutex> lock (stop_mutex_);
6264 // Nothing to do if the timers thread is not running
6365 // or if another thread already signaled to stop.
6466 if (!running_.exchange (false )) {
You can’t perform that action at this time.
0 commit comments