Skip to content

Commit

Permalink
Fix race condition in lf_watchdog_stop
Browse files Browse the repository at this point in the history
  • Loading branch information
erlingrj committed May 2, 2024
1 parent 329528f commit 38ed044
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions core/threaded/watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,15 @@ void lf_watchdog_start(watchdog_t* watchdog, interval_t additional_timeout) {
}

void lf_watchdog_stop(watchdog_t* watchdog) {
// If the watchdog isnt active, then it is no reason to stop it.
// Assumes reactor mutex is already held.
watchdog->expiration = NEVER;

// If lf_watchdog_stop is called very close to lf_watchdog_start, it might
// not have had the time to wake up and start sleeping.
if (!watchdog->active) {
return;
}

// Assumes reactor mutex is already held.
watchdog->expiration = NEVER;
LF_COND_SIGNAL(&watchdog->cond);
}

Expand Down

0 comments on commit 38ed044

Please sign in to comment.