]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
refclock: trim offset in local mode
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 24 Feb 2022 07:45:10 +0000 (08:45 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 24 Feb 2022 10:40:26 +0000 (11:40 +0100)
With the local option, trim offset larger than 1 second to not lose
precision after large steps of the clock.

refclock.c

index cfa958cae2c758693e087b2392912f4330870e39..42acd53caf1a82edded1dbff5e5c47354d8f1d16 100644 (file)
@@ -757,6 +757,12 @@ follow_local(RCL_Instance inst, struct timespec *prev_ref_time, double prev_freq
   LCL_ReadCookedTime(&now, NULL);
   SST_SlewSamples(stats, &now, dfreq, doffset);
   SPF_SlewSamples(inst->filter, &now, dfreq, doffset);
+
+  /* Keep the offset close to zero to not lose precision */
+  if (fabs(offset) >= 1.0) {
+    SST_CorrectOffset(stats, -round(offset));
+    SPF_CorrectOffset(inst->filter, -round(offset));
+  }
 }
 
 static void