]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sources: rework special mode ending with unreachable sources
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 10 Apr 2014 13:45:11 +0000 (15:45 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 10 Apr 2014 15:16:13 +0000 (17:16 +0200)
Instead of giving up when a source has 7 reach updates, continue as long
as at least one source has fewer than 7 updates and can still have 3
samples to be selectable in that number of updates.

When no sources are responding, it will give up sooner.

sources.c

index a4b67e16a99b6bf9ef682e5d2ea55715ca9f0823..d7f7b067a31045ea430157fa8067ca2abd130e16 100644 (file)
--- a/sources.c
+++ b/sources.c
@@ -45,6 +45,7 @@
 #include "nameserv.h"
 #include "mkdirpp.h"
 #include "sched.h"
+#include "regress.h"
 
 /* ================================================== */
 /* Flag indicating that we are initialised */
@@ -346,6 +347,25 @@ SRC_UnsetSelectable(SRC_Instance inst)
 
 /* ================================================== */
 
+static int
+special_mode_end(void)
+{
+    int i;
+
+    for (i = 0; i < n_sources; i++) {
+      /* Don't expect more updates than from an offline iburst NTP source */
+      if (sources[i]->reachability_size >= SOURCE_REACH_BITS - 1)
+        continue;
+
+      /* Check if the source could still have enough samples to be selectable */
+      if (SOURCE_REACH_BITS - 1 - sources[i]->reachability_size +
+            SRC_Samples(sources[i]) >= MIN_SAMPLES_FOR_REGRESS)
+        return 0;
+    }
+
+    return 1;
+}
+
 void
 SRC_UpdateReachability(SRC_Instance inst, int reachable)
 {
@@ -361,9 +381,8 @@ SRC_UpdateReachability(SRC_Instance inst, int reachable)
     SRC_SelectSource(NULL);
   }
 
-  /* End special reference mode on last reachability update from iburst */
-  if (REF_GetMode() != REF_ModeNormal &&
-      inst->reachability_size >= SOURCE_REACH_BITS - 1) {
+  /* Check if special reference update mode failed */
+  if (REF_GetMode() != REF_ModeNormal && special_mode_end()) {
     REF_SetUnsynchronised();
   }
 }