]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sourcestats: enable selection with maxsamples < 3
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 5 Aug 2019 15:53:00 +0000 (17:53 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 6 Aug 2019 14:11:07 +0000 (16:11 +0200)
Setting maxsamples to 1 or 2 prevented the source from being selected as
the regression would always fail. Handle this as a special case with
disabled frequency tracking in order to enable a fast reference update
with the -q/-Q option.

doc/chrony.conf.adoc
sourcestats.c

index e1fbef3bba2abe06916f8f80b6e5e22715f0e63c..cf9468956505efcbd919bba3d736f5f898a94409 100644 (file)
@@ -655,6 +655,10 @@ The *maxsamples* directive sets the default maximum number of samples that
 individual sources in the <<server,*server*>> and <<refclock,*refclock*>>
 directives. The default value is 0, which disables the configurable limit. The
 useful range is 4 to 64.
++
+As a special case, setting *maxsamples* to 1 disables frequency tracking in
+order to make the sources immediately selectable with only one sample. This can
+be useful when *chronyd* is started with the *-q* or *-Q* option.
 
 [[minsamples]]*minsamples* _samples_::
 The *minsamples* directive sets the default minimum number of samples that
index a3f3c5f594e8b914847b8ef6575b8840fe97417a..508a5fdb21c3c5e6ebceea0cfe5bb418f6a77290 100644 (file)
@@ -708,6 +708,13 @@ SST_GetSelectionData(SST_Stats inst, struct timespec *now,
 
   *select_ok = inst->regression_ok;
 
+  /* If maxsamples is too small to have a successful regression, enable the
+     selection as a special case for a fast update/print-once reference mode */
+  if (!*select_ok && inst->n_samples < 3 && inst->n_samples == inst->max_samples) {
+    *std_dev = CNF_GetMaxJitter();
+    *select_ok = 1;
+  }
+
   DEBUG_LOG("n=%d off=%f dist=%f sd=%f first_ago=%f last_ago=%f selok=%d",
             inst->n_samples, offset, *root_distance, *std_dev,
             *first_sample_ago, *last_sample_ago, *select_ok);