]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
rtc: improve accuracy of preinit step
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 18 Aug 2014 11:06:38 +0000 (13:06 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 19 Aug 2014 08:46:35 +0000 (10:46 +0200)
rtc_linux.c

index c0c8a69ee81a04cbec4f6b2ff1020e499260a1f2..64d41992e9fdbe23a4eccd44e213000dfa68a912 100644 (file)
@@ -1027,8 +1027,12 @@ RTC_Linux_TimePreInit(void)
       }
 
       /* Correct time */
-      new_sys_time.tv_sec = rtc_t - (time_t)(0.5 + accumulated_error);
-      new_sys_time.tv_usec = 0;
+
+      new_sys_time.tv_sec = rtc_t;
+      /* Average error in the RTC reading */
+      new_sys_time.tv_usec = 500000;
+
+      UTI_AddDoubleToTimeval(&new_sys_time, -accumulated_error, &new_sys_time);
 
       /* Set system time only if the step is larger than 1 second */
       if (!(gettimeofday(&old_sys_time, NULL) < 0) &&