]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
local: don't remove handlers in finalization
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 21 May 2020 09:47:38 +0000 (11:47 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 21 May 2020 10:42:18 +0000 (12:42 +0200)
Require all handlers to be deregistered by their users before the local
finalization.

local.c
manual.c
ntp_sources.c
reference.c
rtc_linux.c
smooth.c
sys_generic.c

diff --git a/local.c b/local.c
index b4baaac457009cef66df353c9d641bc6765a4277..15c37b1fc6b39584e43293bae5323897a0883298 100644 (file)
--- a/local.c
+++ b/local.c
@@ -185,13 +185,11 @@ LCL_Initialise(void)
 void
 LCL_Finalise(void)
 {
-  while (change_list.next != &change_list)
-    LCL_RemoveParameterChangeHandler(change_list.next->handler,
-                                     change_list.next->anything);
-
-  while (dispersion_notify_list.next != &dispersion_notify_list)
-    LCL_RemoveDispersionNotifyHandler(dispersion_notify_list.next->handler,
-                                      dispersion_notify_list.next->anything);
+  /* Make sure all handlers have been removed */
+  if (change_list.next != &change_list)
+    assert(0);
+  if (dispersion_notify_list.next != &dispersion_notify_list)
+    assert(0);
 }
 
 /* ================================================== */
index bf52d14e0c609f8ba5b2bef62ab4a5bbe86d71ce..98a3aa2a3b7bbdfeb206070eebfe71cfeb04092f 100644 (file)
--- a/manual.c
+++ b/manual.c
@@ -92,6 +92,7 @@ MNL_Initialise(void)
 void
 MNL_Finalise(void)
 {
+  LCL_RemoveParameterChangeHandler(slew_samples, NULL);
 }
 
 /* ================================================== */
index db6cbc8139a3a036e88cc3f5e68e78e3559c39f2..4a548545ba04934adbd69ab8c2ce1672b859e6fe 100644 (file)
@@ -185,6 +185,8 @@ NSR_Finalise(void)
       clean_source_record(record);
   }
 
+  LCL_RemoveParameterChangeHandler(slew_sources, NULL);
+
   ARR_DestroyInstance(records);
   ARR_DestroyInstance(pools);
 
index 553bc96494f727fdc09cde0920a93034388c4f44..74234870668c1d79311a5b7fb594ab92699d8d23 100644 (file)
@@ -304,6 +304,8 @@ REF_Finalise(void)
     update_drift_file(LCL_ReadAbsoluteFrequency(), our_skew);
   }
 
+  LCL_RemoveParameterChangeHandler(handle_slew, NULL);
+
   Free(fb_drifts);
 
   initialised = 0;
index a44a912d2e727a5b1458d62fec7a3e425f45d2f6..08c2a19fa41049e443115f3dd6bdf944e7eb87b9 100644 (file)
@@ -573,6 +573,10 @@ RTC_Linux_Finalise(void)
     (void) RTC_Linux_WriteParameters();
 
   }
+
+  if (rtc_sec)
+    LCL_RemoveParameterChangeHandler(slew_samples, NULL);
+
   Free(rtc_sec);
   Free(rtc_trim);
   Free(system_times);
index 4125ea0d4d32cee4006d3a6e373ef9f755e2b68f..4c350e91c060fb301df85118c437827e55e10fd2 100644 (file)
--- a/smooth.c
+++ b/smooth.c
@@ -272,6 +272,10 @@ void SMT_Initialise(void)
 
 void SMT_Finalise(void)
 {
+  if (!enabled)
+    return;
+
+  LCL_RemoveParameterChangeHandler(handle_slew, NULL);
 }
 
 int SMT_IsEnabled(void)
index 9c785d29ba460c26c704d6fc44128b51c04e88d3..6e29ee2ac878d86a9877cd363188aa896e4a0dce 100644 (file)
@@ -417,6 +417,8 @@ SYS_Generic_Finalise(void)
 
   LCL_ReadRawTime(&now);
   stop_fastslew(&now);
+
+  LCL_RemoveParameterChangeHandler(handle_step, NULL);
 }
 
 /* ================================================== */