]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: set maximum number of iburst samples to size of reach register
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 7 Apr 2014 14:15:40 +0000 (16:15 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 9 Apr 2014 07:59:57 +0000 (09:59 +0200)
Explicitly set the number of iburst samples to the size of the register
to make sure there are at least 7 reachability updates and the
initstepslew mode can be ended.

ntp_core.c
sources.c
sources.h

index 719172bb32e589196391292084789c7a133035b0..3d55d72c95356308febd0496ccaa33b6aa4d2e78 100644 (file)
@@ -186,6 +186,10 @@ struct NCR_Instance_Record {
    a reply to the previous probe */
 #define BURST_TIMEOUT 8.0
 
+/* Number of samples in initial burst */
+#define IBURST_GOOD_SAMPLES 4
+#define IBURST_TOTAL_SAMPLES SOURCE_REACH_BITS
+
 /* Time to wait after sending echo to 'warm up' link */
 #define WARM_UP_DELAY 4.0
 
@@ -345,7 +349,7 @@ NCR_GetInstance(NTP_Remote_Address *remote_addr, NTP_Source_Type type, SourcePar
   }
   
   if (params->iburst) {
-    NCR_InitiateSampleBurst(result, 4, 8);
+    NCR_InitiateSampleBurst(result, IBURST_GOOD_SAMPLES, IBURST_TOTAL_SAMPLES);
   }
 
   result->auto_offline = params->auto_offline;
index 77245ca7c39c5230f902f1c7145a00810d9c13b4..364058a44b14315022a083be4db84573ba30c521 100644 (file)
--- a/sources.c
+++ b/sources.c
@@ -135,9 +135,6 @@ static int selected_source_index; /* Which source index is currently
                                      selected (set to INVALID_SOURCE
                                      if no current valid reference) */
 
-/* Keep reachability status for last 8 samples */
-#define REACH_BITS 8
-
 /* Score needed to replace the currently selected source */
 #define SCORE_LIMIT 10.0
 
@@ -354,9 +351,9 @@ SRC_UpdateReachability(SRC_Instance inst, int reachable)
 {
   inst->reachability <<= 1;
   inst->reachability |= !!reachable;
-  inst->reachability &= ~(-1 << REACH_BITS);
+  inst->reachability &= ~(-1 << SOURCE_REACH_BITS);
 
-  if (inst->reachability_size < REACH_BITS)
+  if (inst->reachability_size < SOURCE_REACH_BITS)
       inst->reachability_size++;
 
   if (!reachable && inst->index == selected_source_index) {
@@ -366,7 +363,7 @@ SRC_UpdateReachability(SRC_Instance inst, int reachable)
 
   /* End special reference mode on last reachability update from iburst */
   if (REF_GetMode() != REF_ModeNormal &&
-      inst->reachability_size >= REACH_BITS - 1) {
+      inst->reachability_size >= SOURCE_REACH_BITS - 1) {
     REF_SetUnsynchronised();
   }
 }
@@ -458,7 +455,7 @@ combine_sources(int n_sel_sources, struct timeval *ref_time, double *offset,
          fabs(*frequency - src_frequency) >
            combine_limit * (*skew + src_skew + LCL_GetMaxClockError()))) {
       /* Use a smaller penalty in first few updates */
-      sources[index]->outlier = sources[index]->reachability_size >= REACH_BITS ?
+      sources[index]->outlier = sources[index]->reachability_size >= SOURCE_REACH_BITS ?
                                 OUTLIER_PENALTY : 1;
     } else if (sources[index]->outlier) {
       sources[index]->outlier--;
index d06d25d5521ea14f186543ab8668df558c342cca..3037ee9b9fcd89088db785453d3a7ea1b8ea19af 100644 (file)
--- a/sources.h
+++ b/sources.h
@@ -34,6 +34,9 @@
 #include "ntp.h"
 #include "reports.h"
 
+/* Size of the source reachability register */
+#define SOURCE_REACH_BITS 8
+
 /* This datatype is used to hold information about sources.  The
    instance must be passed when calling many of the interface
    functions */