From 3cef7f975cd2ecdceb62c72dd31f96c515744acc Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Wed, 3 Feb 2021 10:25:41 +0100 Subject: [PATCH] main: cancel clock correction before dumping sources On exit, cancel the remaining clock correction before measurements are saved to dumpdir to fix them for the state in which chronyd will start again. --- local.c | 13 +++++++++++++ local.h | 3 +++ main.c | 1 + 3 files changed, 17 insertions(+) diff --git a/local.c b/local.c index c0916cfc..df4cee7b 100644 --- a/local.c +++ b/local.c @@ -687,6 +687,19 @@ LCL_MakeStep(void) /* ================================================== */ +void +LCL_CancelOffsetCorrection(void) +{ + struct timespec raw; + double correction; + + LCL_ReadRawTime(&raw); + LCL_GetOffsetCorrection(&raw, &correction, NULL); + LCL_AccumulateOffset(correction, 0.0); +} + +/* ================================================== */ + int LCL_CanSystemLeap(void) { diff --git a/local.h b/local.h index 7ceb76ad..1a6fb970 100644 --- a/local.h +++ b/local.h @@ -197,6 +197,9 @@ extern void LCL_Finalise(void); to a timezone problem. */ extern int LCL_MakeStep(void); +/* Routine to cancel the outstanding system clock correction */ +extern void LCL_CancelOffsetCorrection(void); + /* Check if the system driver supports leap seconds, i.e. LCL_SetSystemLeap does something */ extern int LCL_CanSystemLeap(void); diff --git a/main.c b/main.c index b2149b1e..bde2e6c1 100644 --- a/main.c +++ b/main.c @@ -104,6 +104,7 @@ MAI_CleanupAndExit(void) { if (!initialised) exit(exit_status); + LCL_CancelOffsetCorrection(); SRC_DumpSources(); /* Don't update clock when removing sources */ -- 2.47.2