From: Miroslav Lichvar Date: Wed, 4 Jun 2014 14:44:14 +0000 (+0200) Subject: reference: cook timestamp when setting reference X-Git-Tag: 1.30-pre1~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9a8503c6bca5d71ec93af1e66692705bb0348e3;p=thirdparty%2Fchrony.git reference: cook timestamp when setting reference This is a partial revert of 8aa9eb19c826f3ea4a9c2ce5e3a71b74aeeb99d0. With the new generic driver cooking is cheap and it should be slighly more accurate than reusing offset correction from the scheduler timestamps. --- diff --git a/reference.c b/reference.c index 2d3c9cb0..80acc6ff 100644 --- a/reference.c +++ b/reference.c @@ -791,7 +791,7 @@ REF_SetReference(int stratum, double elapsed; double correction_rate; double uncorrected_offset; - struct timeval now, raw_now, ev_now, ev_raw_now; + struct timeval now, raw_now; assert(initialised); @@ -824,10 +824,7 @@ REF_SetReference(int stratum, } LCL_ReadRawTime(&raw_now); - - /* This is cheaper than calling LCL_CookTime */ - SCH_GetLastEventTime(&ev_now, NULL, &ev_raw_now); - UTI_DiffTimevalsToDouble(&uncorrected_offset, &ev_now, &ev_raw_now); + LCL_GetOffsetCorrection(&raw_now, &uncorrected_offset, NULL); UTI_AddDoubleToTimeval(&raw_now, uncorrected_offset, &now); UTI_DiffTimevalsToDouble(&elapsed, &now, ref_time); @@ -998,9 +995,9 @@ REF_SetUnsynchronised(void) return; } - /* This is cheaper than calling LCL_CookTime */ - SCH_GetLastEventTime(&now, NULL, &now_raw); - UTI_DiffTimevalsToDouble(&uncorrected_offset, &now, &now_raw); + LCL_ReadRawTime(&now_raw); + LCL_GetOffsetCorrection(&now_raw, &uncorrected_offset, NULL); + UTI_AddDoubleToTimeval(&now_raw, uncorrected_offset, &now); if (fb_drifts) { schedule_fb_drift(&now);