From: Miroslav Lichvar Date: Mon, 13 Feb 2012 15:54:18 +0000 (+0100) Subject: Better estimate RTC offset right after trim X-Git-Tag: 1.27-pre1~14 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d6c447a445ee8d870f5d037bd21d786c2ea40c29;p=thirdparty%2Fchrony.git Better estimate RTC offset right after trim --- diff --git a/rtc_linux.c b/rtc_linux.c index aa172e14..2395bb85 100644 --- a/rtc_linux.c +++ b/rtc_linux.c @@ -1045,9 +1045,10 @@ RTC_Linux_Trim(void) n_samples = 0; operating_mode = OM_AFTERTRIM; - /* Zero the offset in case writertc is called or chronyd + /* Estimate the offset in case writertc is called or chronyd is terminated during rapid sampling */ - coef_seconds_fast = 0.0; + coef_seconds_fast = -now.tv_usec / 1e6 + 0.5; + coef_ref_time = now; /* And start rapid sampling, interrupts on now */ if (timeout_running) {