Skip to content

Commit

Permalink
Revert change to report interval logic
Browse files Browse the repository at this point in the history
75acb36 changed the `else` block to an `else if` at line 418 which caused the `pthread_cond_wait` call to fall outside of the block. That resulted in the decision thread checking for fan events a second time in the same iteration, and this time blocking without a report timeout.

The symptom was not a full freeze of the decision thread, just degraded performance, and you could recover the system by killing fapolicyd. This only occurred when a report interval was enabled, when disabled fapolicyd functioned normally.

The fix is to restore the else so `pthread_cond_wait` falls within the else and is only called when reporting is disabled.
  • Loading branch information
jw3 committed Nov 26, 2024
1 parent f76484b commit 8be8211
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/daemon/notify.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,14 +414,17 @@ static void *decision_thread_main(void *arg)
pthread_cond_timedwait(&do_decision,
&decision_lock,
&rpt_timeout);
} else if (run_stats) {
rpt_write();
run_stats = 0;
} else {
if (run_stats) {
rpt_write();
run_stats = 0;
}
if (stop)
break;

// no interval reports, await a fan event indefinitely
pthread_cond_wait(&do_decision, &decision_lock);
}
// no interval reports, await a fan event indefinitely
if (stop)
break;
pthread_cond_wait(&do_decision, &decision_lock);
}

if (stop) {
Expand Down

0 comments on commit 8be8211

Please sign in to comment.