]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
refclock: restart local mode after losing lock
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 11 May 2022 09:36:57 +0000 (11:36 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 11 May 2022 12:27:18 +0000 (14:27 +0200)
A refclock in the local mode is locked to itself. When the maxlockage
check failed after missing some samples, it failed permanently and the
refclock was not able to accumulate any new samples.

When the check fails, drop all samples and reset the source to start
from scratch.

Reported-by: Dan Drown <dan-ntp@drown.org>
refclock.c

index 272777ab7c95a26055e42a33b01c179de0e7e0ce..b59acc3502abc24b8921d94c9a3721844013860e 100644 (file)
@@ -592,8 +592,14 @@ RCL_AddCookedPulse(RCL_Instance instance, struct timespec *cooked_time,
 
     sample_diff = UTI_DiffTimespecsToDouble(cooked_time, &ref_sample.time);
     if (fabs(sample_diff) >= (double)instance->max_lock_age / rate) {
-      DEBUG_LOG("refclock pulse ignored samplediff=%.9f",
-          sample_diff);
+      DEBUG_LOG("refclock pulse ignored samplediff=%.9f", sample_diff);
+
+      /* Restart the local mode */
+      if (instance->local) {
+        LOG(LOGS_WARN, "Local refclock lost lock");
+        SPF_DropSamples(instance->filter);
+        SRC_ResetInstance(instance->source);
+      }
       return 0;
     }