]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Don't apply outlyer penalty at beginning
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 13 Jun 2013 16:19:17 +0000 (18:19 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 13 Jun 2013 16:20:53 +0000 (18:20 +0200)
Wait until the reach register is full to allow marking a source as
outlyer for 32 updates. This makes start nicer with iburst.

sources.c

index 2cb1ec418200a41b9c932780197e6caf46b08835..dd201205483eda1cd5eefe9f4fbcaa7c7b7b585d 100644 (file)
--- a/sources.c
+++ b/sources.c
@@ -93,6 +93,9 @@ struct SRC_Instance_Record {
   /* Reachability register */
   int reachability;
 
+  /* Flag indicating that only few samples were accumulated so far */
+  int beginning;
+
   /* Updates left before resetting outlyer status */
   int outlyer;
 
@@ -216,6 +219,7 @@ SRC_Instance SRC_CreateNewInstance(uint32_t ref_id, SRC_Type type, SRC_SelectOpt
   result->ip_addr = addr;
   result->selectable = 0;
   result->reachability = 0;
+  result->beginning = 1;
   result->outlyer = 0;
   result->status = SRC_BAD_STATS;
   result->type = type;
@@ -360,6 +364,10 @@ SRC_UpdateReachability(SRC_Instance inst, int reachable)
   inst->reachability |= !!reachable;
   inst->reachability &= ~(-1 << REACH_BITS);
 
+  /* The beginning is over when the first sample is at the end of the register */
+  if (inst->reachability & (1 << (REACH_BITS - 1)))
+      inst->beginning = 0;
+
   if (!reachable && inst->index == selected_source_index) {
     /* Try to select a better source */
     SRC_SelectSource(0);
@@ -446,7 +454,7 @@ combine_sources(int n_sel_sources, struct timeval *ref_time, double *offset,
            (reselect_distance + sources[selected_source_index]->sel_info.root_distance) ||
          fabs(*frequency - src_frequency) >
            combine_limit * (*skew + src_skew + LCL_GetMaxClockError()))) {
-      sources[index]->outlyer = OUTLYER_PENALTY;
+      sources[index]->outlyer = !sources[index]->beginning ? OUTLYER_PENALTY : 1;
     }
 
     if (sources[index]->outlyer) {