Skip to content

Commit

Permalink
FIX: dont attempt to reschedule timers that are deleted (FIXES: #1048) (
Browse files Browse the repository at this point in the history
  • Loading branch information
braindigitalis authored Feb 19, 2024
1 parent 23a9932 commit 9ccd5db
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/dpp/cluster/timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,21 @@ void cluster::tick_timers() {
}
}
for (auto & t : scheduled) {
timer handle = t->handle;
/* Call handler */
t->on_tick(t->handle);
/* Reschedule for next tick */
timer_reschedule(t);
/* Reschedule if it wasn't deleted.
* Note: We wrap the .contains() check in a lambda as it needs locking
* for thread safety, but timer_rescheudle also locks the container, so this
* is the cleanest way to do it.
*/
bool not_deleted = ([handle, this]() -> bool {
std::lock_guard<std::mutex> l(timer_guard);
return timer_list.find(handle) != timer_list.end();
}());
if (not_deleted) {
timer_reschedule(t);
}
}
}

Expand Down

0 comments on commit 9ccd5db

Please sign in to comment.