]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
refclock: don't include average dispersion in unfiltered samples
authorMiroslav Lichvar <mlichvar@redhat.com>
Fri, 23 May 2014 13:22:11 +0000 (15:22 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 23 May 2014 14:15:28 +0000 (16:15 +0200)
The dispersion of refclock samples before filtering now includes only
offset correction error and precision.

This should fix a problem where locked PPS got stuck with large average
dispersion and didn't accept new samples due failing check of offset
and dispersion.

refclock.c

index 0cd4754103fb92f0aad0f10b86b55746eefd8929..67f0588987e36b2abca66b390cb58094529ee3c8 100644 (file)
@@ -351,7 +351,7 @@ RCL_AddSample(RCL_Instance instance, struct timeval *sample_time, double offset,
 
   LCL_GetOffsetCorrection(sample_time, &correction, &dispersion);
   UTI_AddDoubleToTimeval(sample_time, correction, &cooked_time);
-  dispersion += instance->precision + filter_get_avg_sample_dispersion(&instance->filter);
+  dispersion += instance->precision;
 
   if (!valid_sample_time(instance, sample_time))
     return 0;
@@ -391,7 +391,7 @@ RCL_AddPulse(RCL_Instance instance, struct timeval *pulse_time, double second)
   leap = LEAP_Normal;
   LCL_GetOffsetCorrection(pulse_time, &correction, &dispersion);
   UTI_AddDoubleToTimeval(pulse_time, correction, &cooked_time);
-  dispersion += instance->precision + filter_get_avg_sample_dispersion(&instance->filter);
+  dispersion += instance->precision;
 
   if (!valid_sample_time(instance, pulse_time))
     return 0;
@@ -418,6 +418,8 @@ RCL_AddPulse(RCL_Instance instance, struct timeval *pulse_time, double second)
       return 0;
     }
 
+    ref_dispersion += filter_get_avg_sample_dispersion(&refclocks[instance->lock_ref].filter);
+
     UTI_DiffTimevalsToDouble(&sample_diff, &cooked_time, &ref_sample_time);
     if (fabs(sample_diff) >= 2.0 / rate) {
       DEBUG_LOG(LOGF_Refclock, "refclock pulse ignored samplediff=%.9f",
@@ -829,8 +831,6 @@ filter_get_sample(struct MedianFilter *filter, struct timeval *sample_time, doub
   y /= n;
   e /= n;
 
-  e -= sqrt(filter->avg_var);
-
   if (n >= 4) {
     double b0, b1, s2, sb0, sb1;