]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sched: stop dispatching timeouts on exit
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 13 Jan 2021 11:51:57 +0000 (12:51 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 14 Jan 2021 17:17:48 +0000 (18:17 +0100)
Check in the dispatch loop whether the need_to_exit flag was set.

sched.c

diff --git a/sched.c b/sched.c
index 8d911166cf9afd6d6cf618b46ae3132d505bd318..a4487c39289ac7fcc858e4ad267e9d99e9205596 100644 (file)
--- a/sched.c
+++ b/sched.c
@@ -506,7 +506,7 @@ dispatch_timeouts(struct timespec *now) {
   n_entries_on_start = n_timer_queue_entries;
   n_done = 0;
 
-  while (1) {
+  do {
     LCL_ReadRawTime(now);
 
     if (!(n_timer_queue_entries > 0 &&
@@ -542,7 +542,8 @@ dispatch_timeouts(struct timespec *now) {
         n_done > 4 * MAX(n_timer_queue_entries, n_entries_on_start) &&
         fabs(UTI_DiffTimespecsToDouble(now, &last_select_ts_raw)) / n_done < 0.01)
       LOG_FATAL("Possible infinite loop in scheduling");
-  }
+
+  } while (!need_to_exit);
 }
 
 /* ================================================== */