]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
main: cancel clock correction before dumping sources
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 3 Feb 2021 09:25:41 +0000 (10:25 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 3 Feb 2021 10:06:00 +0000 (11:06 +0100)
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
local.h
main.c

diff --git a/local.c b/local.c
index c0916cfc48a7246b5347e973dd6cbe8c806e7ef8..df4cee7bcdae47c2f0c3d6f434c7c7613fce8a8a 100644 (file)
--- 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 7ceb76ad50bb051e18fbd52b182f84981c27cc54..1a6fb970e15f14cb7045a09783506204cd1370ba 100644 (file)
--- 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 b2149b1eea32a745f57365888b1b6d2151f7e885..bde2e6c10f5cb8ed7613c9c75a2549aacdbd8d00 100644 (file)
--- 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 */