local: don't remove handlers in finalization

Require all handlers to be deregistered by their users before the local
finalization.
This commit is contained in:
Miroslav Lichvar 2020-05-21 11:47:38 +02:00
parent bf92314dc4
commit 5f6f265f80
7 changed files with 20 additions and 7 deletions

12
local.c
View file

@ -185,13 +185,11 @@ LCL_Initialise(void)
void void
LCL_Finalise(void) LCL_Finalise(void)
{ {
while (change_list.next != &change_list) /* Make sure all handlers have been removed */
LCL_RemoveParameterChangeHandler(change_list.next->handler, if (change_list.next != &change_list)
change_list.next->anything); assert(0);
if (dispersion_notify_list.next != &dispersion_notify_list)
while (dispersion_notify_list.next != &dispersion_notify_list) assert(0);
LCL_RemoveDispersionNotifyHandler(dispersion_notify_list.next->handler,
dispersion_notify_list.next->anything);
} }
/* ================================================== */ /* ================================================== */

View file

@ -92,6 +92,7 @@ MNL_Initialise(void)
void void
MNL_Finalise(void) MNL_Finalise(void)
{ {
LCL_RemoveParameterChangeHandler(slew_samples, NULL);
} }
/* ================================================== */ /* ================================================== */

View file

@ -185,6 +185,8 @@ NSR_Finalise(void)
clean_source_record(record); clean_source_record(record);
} }
LCL_RemoveParameterChangeHandler(slew_sources, NULL);
ARR_DestroyInstance(records); ARR_DestroyInstance(records);
ARR_DestroyInstance(pools); ARR_DestroyInstance(pools);

View file

@ -304,6 +304,8 @@ REF_Finalise(void)
update_drift_file(LCL_ReadAbsoluteFrequency(), our_skew); update_drift_file(LCL_ReadAbsoluteFrequency(), our_skew);
} }
LCL_RemoveParameterChangeHandler(handle_slew, NULL);
Free(fb_drifts); Free(fb_drifts);
initialised = 0; initialised = 0;

View file

@ -573,6 +573,10 @@ RTC_Linux_Finalise(void)
(void) RTC_Linux_WriteParameters(); (void) RTC_Linux_WriteParameters();
} }
if (rtc_sec)
LCL_RemoveParameterChangeHandler(slew_samples, NULL);
Free(rtc_sec); Free(rtc_sec);
Free(rtc_trim); Free(rtc_trim);
Free(system_times); Free(system_times);

View file

@ -272,6 +272,10 @@ void SMT_Initialise(void)
void SMT_Finalise(void) void SMT_Finalise(void)
{ {
if (!enabled)
return;
LCL_RemoveParameterChangeHandler(handle_slew, NULL);
} }
int SMT_IsEnabled(void) int SMT_IsEnabled(void)

View file

@ -417,6 +417,8 @@ SYS_Generic_Finalise(void)
LCL_ReadRawTime(&now); LCL_ReadRawTime(&now);
stop_fastslew(&now); stop_fastslew(&now);
LCL_RemoveParameterChangeHandler(handle_step, NULL);
} }
/* ================================================== */ /* ================================================== */