]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Add refclock option for delay
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 27 Oct 2009 13:02:16 +0000 (14:02 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 27 Oct 2009 13:02:16 +0000 (14:02 +0100)
This is useful when refclocks don't agree on time, increasing the
delay will widen the interval used in the source selection algorithm.

conf.c
refclock.c
refclock.h

diff --git a/conf.c b/conf.c
index 2135c760d62820d95ca5b168d05f037af8170a0a..050bef8fd64b06ccccd34bbd601f1780ac17e780 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -431,7 +431,7 @@ parse_refclock(const char *line)
 {
   int i, n, poll, dpoll, filter_length;
   unsigned long ref_id;
-  double offset;
+  double offset, delay;
   const char *tmp;
   char name[5], cmd[10 + 1], *param;
   unsigned char ref[5];
@@ -444,6 +444,7 @@ parse_refclock(const char *line)
   dpoll = 0;
   filter_length = 15;
   offset = 0.0;
+  delay = 1e-9;
   ref_id = 0;
 
   if (sscanf(line, "%4s%n", name, &n) != 1) {
@@ -488,6 +489,9 @@ parse_refclock(const char *line)
     } else if (!strncasecmp(cmd, "offset", 6)) {
       if (sscanf(line, "%lf%n", &offset, &n) != 1)
         break;
+    } else if (!strncasecmp(cmd, "delay", 5)) {
+      if (sscanf(line, "%lf%n", &delay, &n) != 1)
+        break;
     } else {
       LOG(LOGS_WARN, LOGF_Configure, "Unknown refclock parameter %s at line %d", cmd, line_number);
       break;
@@ -501,6 +505,7 @@ parse_refclock(const char *line)
   refclock_sources[i].poll = poll;
   refclock_sources[i].filter_length = filter_length;
   refclock_sources[i].offset = offset;
+  refclock_sources[i].delay = delay;
   refclock_sources[i].ref_id = ref_id;
 
   n_refclock_sources++;
index 50c3a429ba905be5290b52a5e26a3a30591d7fa4..a633870be7fa917f3a6493e67302d2af45a06873 100644 (file)
@@ -62,6 +62,7 @@ struct RCL_Instance_Record {
   struct MedianFilter filter;
   unsigned long ref_id;
   double offset;
+  double delay;
   SCH_TimeoutID timeout_id;
   SRC_Instance source;
 };
@@ -132,6 +133,7 @@ RCL_AddRefclock(RefclockParameters *params)
   inst->driver_polled = 0;
   inst->leap_status = 0;
   inst->offset = params->offset;
+  inst->delay = params->delay;
   inst->timeout_id = -1;
   inst->source = NULL;
 
@@ -269,7 +271,7 @@ poll_timeout(void *arg)
 #endif
       SRC_SetReachable(inst->source);
       SRC_AccumulateSample(inst->source, &sample_time, offset,
-          1e-9, dispersion, 1e-9, dispersion, 0, inst->leap_status);
+          inst->delay, dispersion, inst->delay, dispersion, 0, inst->leap_status);
       inst->missed_samples = 0;
     } else {
       inst->missed_samples++;
index 3c6f45a4464027d6e0b96c0d315325a8626372f1..d409886383f41520dcf372696e84450375533290 100644 (file)
@@ -39,6 +39,7 @@ typedef struct {
   int filter_length;
   unsigned long ref_id;
   double offset;
+  double delay;
 } RefclockParameters;
 
 typedef struct RCL_Instance_Record *RCL_Instance;