From: Miroslav Lichvar Date: Thu, 24 Feb 2022 07:45:10 +0000 (+0100) Subject: refclock: trim offset in local mode X-Git-Tag: 4.3-pre1~54 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=55717c1ccdf75aaa7b30570ac3478237a66a89f1;p=thirdparty%2Fchrony.git refclock: trim offset in local mode With the local option, trim offset larger than 1 second to not lose precision after large steps of the clock. --- diff --git a/refclock.c b/refclock.c index cfa958ca..42acd53c 100644 --- a/refclock.c +++ b/refclock.c @@ -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