]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: include local error in hwclock samples
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 9 May 2017 15:43:33 +0000 (17:43 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 26 May 2017 11:33:53 +0000 (13:33 +0200)
ntp_io_linux.c

index 6af4995aa07239227eb31741cad01a237243b7bd..cb77dd7e57d11fc2ff09beb82f08a03ad843990c 100644 (file)
@@ -373,16 +373,18 @@ process_hw_timestamp(struct Interface *iface, struct timespec *hw_ts,
                      NTP_Local_Timestamp *local_ts, int rx_ntp_length, int family)
 {
   struct timespec sample_phc_ts, sample_sys_ts, sample_local_ts, ts;
-  double rx_correction, ts_delay, err;
+  double rx_correction, ts_delay, phc_err, local_err;
   int l2_length;
 
   if (HCL_NeedsNewSample(iface->clock, &local_ts->ts)) {
     if (!SYS_Linux_GetPHCSample(iface->phc_fd, iface->phc_nocrossts, iface->precision,
-                                &iface->phc_mode, &sample_phc_ts, &sample_sys_ts, &err))
+                                &iface->phc_mode, &sample_phc_ts, &sample_sys_ts,
+                                &phc_err))
       return;
 
-    LCL_CookTime(&sample_sys_ts, &sample_local_ts, NULL);
-    HCL_AccumulateSample(iface->clock, &sample_phc_ts, &sample_local_ts, err);
+    LCL_CookTime(&sample_sys_ts, &sample_local_ts, &local_err);
+    HCL_AccumulateSample(iface->clock, &sample_phc_ts, &sample_local_ts,
+                         phc_err + local_err);
 
     update_interface_speed(iface);
   }
@@ -405,7 +407,7 @@ process_hw_timestamp(struct Interface *iface, struct timespec *hw_ts,
   else if (rx_ntp_length && iface->rx_comp)
     UTI_AddDoubleToTimespec(hw_ts, -iface->rx_comp, hw_ts);
 
-  if (!HCL_CookTime(iface->clock, hw_ts, &ts, &err))
+  if (!HCL_CookTime(iface->clock, hw_ts, &ts, &local_err))
     return;
 
   ts_delay = UTI_DiffTimespecsToDouble(&local_ts->ts, &ts);
@@ -416,7 +418,7 @@ process_hw_timestamp(struct Interface *iface, struct timespec *hw_ts,
   }
 
   local_ts->ts = ts;
-  local_ts->err = err;
+  local_ts->err = local_err;
   local_ts->source = NTP_TS_HARDWARE;
 }