]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
refclock: make maximum lock age configurable
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 8 Dec 2016 13:40:11 +0000 (14:40 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 8 Dec 2016 13:47:38 +0000 (14:47 +0100)
The maxlockage option specifies in number of pulses how old can be
samples from the refclock specified by the lock option to be paired with
the pulses. Increasing this value is useful when the samples are
produced at a lower rate than the pulses.

conf.c
doc/chrony.conf.adoc
refclock.c
refclock.h

diff --git a/conf.c b/conf.c
index be3a189d5cf15b5983e02561d55491412b4cab9a..7500fd9554d597677e3073af3ad8f32270327e47 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -674,6 +674,7 @@ static void
 parse_refclock(char *line)
 {
   int n, poll, dpoll, filter_length, pps_rate, min_samples, max_samples, sel_options;
+  int max_lock_age;
   uint32_t ref_id, lock_ref_id;
   double offset, delay, precision, max_dispersion;
   char *p, *cmd, *name, *param;
@@ -692,6 +693,7 @@ parse_refclock(char *line)
   precision = 0.0;
   max_dispersion = 0.0;
   ref_id = 0;
+  max_lock_age = 2;
   lock_ref_id = 0;
 
   if (!*line) {
@@ -742,6 +744,9 @@ parse_refclock(char *line)
     } else if (!strcasecmp(cmd, "minsamples")) {
       if (sscanf(line, "%d%n", &min_samples, &n) != 1)
         break;
+    } else if (!strcasecmp(cmd, "maxlockage")) {
+      if (sscanf(line, "%d%n", &max_lock_age, &n) != 1)
+        break;
     } else if (!strcasecmp(cmd, "maxsamples")) {
       if (sscanf(line, "%d%n", &max_samples, &n) != 1)
         break;
@@ -795,6 +800,7 @@ parse_refclock(char *line)
   refclock->precision = precision;
   refclock->max_dispersion = max_dispersion;
   refclock->ref_id = ref_id;
+  refclock->max_lock_age = max_lock_age;
   refclock->lock_ref_id = lock_ref_id;
 }
 
index 123666ad0612f04477a4d2ad63e776a114f98d2b..6e9ab909e8c1052fa625763cd1ba6282e6528bb7 100644 (file)
@@ -434,6 +434,11 @@ This option sets the rate of the pulses in the PPS signal (in Hz). This option
 controls how the pulses will be completed with real time. To actually receive
 more than one pulse per second, a negative *dpoll* has to be specified (-3 for
 a 5Hz signal). The default is 1.
+*maxlockage* _pulses_:::
+This option specifies in number of pulses how old can be samples from the
+refclock specified by the *lock* option to be paired with the pulses.
+Increasing this value is useful when the samples are produced at a lower rate
+than the pulses. The default is 2.
 *offset* _offset_:::
 This option can be used to compensate for a constant error. The specified
 offset (in seconds) is applied to all samples produced by the reference clock.
index 1fceea48cfa89ab0f4e0551ffacb54bc488289db..4686af0252ba26752c165b5812da28792ec478be 100644 (file)
@@ -77,6 +77,7 @@ struct RCL_Instance_Record {
   int leap_status;
   int pps_rate;
   int pps_active;
+  int max_lock_age;
   struct MedianFilter filter;
   uint32_t ref_id;
   uint32_t lock_ref;
@@ -202,6 +203,7 @@ RCL_AddRefclock(RefclockParameters *params)
   inst->leap_status = LEAP_Normal;
   inst->pps_rate = params->pps_rate;
   inst->pps_active = 0;
+  inst->max_lock_age = params->max_lock_age;
   inst->lock_ref = params->lock_ref_id;
   inst->offset = params->offset;
   inst->delay = params->delay;
@@ -444,7 +446,7 @@ RCL_AddPulse(RCL_Instance instance, struct timespec *pulse_time, double second)
     ref_dispersion += filter_get_avg_sample_dispersion(&lock_refclock->filter);
 
     sample_diff = UTI_DiffTimespecsToDouble(&cooked_time, &ref_sample_time);
-    if (fabs(sample_diff) >= 2.0 / rate) {
+    if (fabs(sample_diff) >= (double)instance->max_lock_age / rate) {
       DEBUG_LOG(LOGF_Refclock, "refclock pulse ignored samplediff=%.9f",
           sample_diff);
       return 0;
index e4781f02dcc01b5eb02979d9f83bd064e4e35334..7b76c235a1992c4eed3457abc15ac0410a57a5cf 100644 (file)
@@ -41,6 +41,7 @@ typedef struct {
   int min_samples;
   int max_samples;
   int sel_options;
+  int max_lock_age;
   uint32_t ref_id;
   uint32_t lock_ref_id;
   double offset;