Skip to content

Commit

Permalink
Check stop flag before waiting
Browse files Browse the repository at this point in the history
If the stop flag is set before starting a wait, break out of the loop.
With the move closing the FANOTIFY fd, we need to check the flag or
this thread can wait for an event that will never come since fanotofy
was just unmarked.
  • Loading branch information
stevegrubb committed May 26, 2024
1 parent 5e23f8a commit a6bf91d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/daemon/notify.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,8 @@ static void *decision_thread_main(void *arg)
struct timespec rpt_timeout;

// if an interval was configured, reports are enabled
if (rpt_interval) {
if (rpt_interval)
rpt_init(&rpt_timeout);
}

// start with a fresh report
run_stats = 1;
Expand Down Expand Up @@ -410,6 +409,8 @@ static void *decision_thread_main(void *arg)
}
// await a fan event, timing out at the
// next report interval
if (stop)
break;
pthread_cond_timedwait(&do_decision,
&decision_lock,
&rpt_timeout);
Expand All @@ -418,11 +419,16 @@ static void *decision_thread_main(void *arg)
run_stats = 0;
}
// no interval reports, await a fan event indefinitely
if (stop)
break;
pthread_cond_wait(&do_decision, &decision_lock);
}

if (stop)
if (stop) {
msg(LOG_DEBUG, "Exiting decision thread");
pthread_mutex_unlock(&decision_lock);
return NULL;
}

alive = 1;
rpt_is_stale = 1;
Expand Down

0 comments on commit a6bf91d

Please sign in to comment.