]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sourcestats: move leap status to sources
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 11 Mar 2020 14:21:57 +0000 (15:21 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 12 Mar 2020 11:09:50 +0000 (12:09 +0100)
sources.c
sourcestats.c
sourcestats.h

index 2db0299f3612166c423fd2ba32c7a7c4e4af4a3b..58cc4f2b85fa3a425434807b749ced64f385c716 100644 (file)
--- a/sources.c
+++ b/sources.c
@@ -54,7 +54,6 @@ static int initialised = 0;
 /* ================================================== */
 /* Structure used to hold info for selecting between sources */
 struct SelectInfo {
-  NTP_Leap leap;
   int stratum;
   int select_ok;
   double std_dev;
@@ -126,6 +125,9 @@ struct SRC_Instance_Record {
   double sel_score;
 
   struct SelectInfo sel_info;
+
+  /* Latest leap status */
+  NTP_Leap leap;
 };
 
 /* ================================================== */
@@ -298,6 +300,7 @@ SRC_ResetInstance(SRC_Instance instance)
   instance->distant = 0;
   instance->status = SRC_BAD_STATS;
   instance->sel_score = 1.0;
+  instance->leap = LEAP_Unsynchronised;
 
   SST_ResetInstance(instance->stats);
 }
@@ -348,6 +351,7 @@ SRC_AccumulateSample(SRC_Instance inst, NTP_Sample *sample)
 
   SST_AccumulateSample(inst->stats, sample);
   SST_DoNewRegression(inst->stats);
+  inst->leap = sample->leap;
 }
 
 /* ================================================== */
@@ -642,7 +646,7 @@ SRC_SelectSource(SRC_Instance updated_inst)
     }
 
     si = &sources[i]->sel_info;
-    SST_GetSelectionData(sources[i]->stats, &now, &si->stratum, &si->leap,
+    SST_GetSelectionData(sources[i]->stats, &now, &si->stratum,
                          &si->lo_limit, &si->hi_limit, &si->root_distance,
                          &si->std_dev, &first_sample_ago,
                          &si->last_sample_ago, &si->select_ok);
@@ -921,9 +925,9 @@ SRC_SelectSource(SRC_Instance updated_inst)
     if (best_trust_depth && !(sources[index]->sel_options & SRC_SELECT_TRUST))
       continue;
     leap_votes++;
-    if (sources[index]->sel_info.leap == LEAP_InsertSecond)
+    if (sources[index]->leap == LEAP_InsertSecond)
       leap_ins++;
-    else if (sources[index]->sel_info.leap == LEAP_DeleteSecond)
+    else if (sources[index]->leap == LEAP_DeleteSecond)
       leap_del++;
   }
 
index d0514c30f08da5e3d643dbac9cee810c9336e905..c93b5e4c8e042ef13afb575649a997c69b993e66 100644 (file)
@@ -180,9 +180,6 @@ struct SST_Stats_Record {
 
   /* The stratum from the last accumulated sample */
   int stratum;
-
-  /* The leap status from the last accumulated sample */
-  NTP_Leap leap;
 };
 
 /* ================================================== */
@@ -258,7 +255,6 @@ SST_ResetInstance(SST_Stats inst)
   inst->nruns = 0;
   inst->asymmetry_run = 0;
   inst->asymmetry = 0.0;
-  inst->leap = LEAP_Unsynchronised;
 }
 
 /* ================================================== */
@@ -326,7 +322,6 @@ SST_AccumulateSample(SST_Stats inst, NTP_Sample *sample)
   inst->root_delays[m] = sample->root_delay;
   inst->root_dispersions[m] = sample->root_dispersion;
   inst->stratum = sample->stratum;
-  inst->leap = sample->leap;
  
   if (inst->peer_delays[n] < inst->fixed_min_delay)
     inst->peer_delays[n] = 2.0 * inst->fixed_min_delay - inst->peer_delays[n];
@@ -655,7 +650,7 @@ SST_GetFrequencyRange(SST_Stats inst,
 
 void
 SST_GetSelectionData(SST_Stats inst, struct timespec *now,
-                     int *stratum, NTP_Leap *leap,
+                     int *stratum,
                      double *offset_lo_limit,
                      double *offset_hi_limit,
                      double *root_distance,
@@ -676,7 +671,6 @@ SST_GetSelectionData(SST_Stats inst, struct timespec *now,
   j = get_buf_index(inst, inst->best_single_sample);
 
   *stratum = inst->stratum;
-  *leap = inst->leap;
   *std_dev = inst->std_dev;
 
   sample_elapsed = fabs(UTI_DiffTimespecsToDouble(now, &inst->sample_times[i]));
index a321d3aff4ca41e8060b40b83e9c4bb3e2628446..72fd54688e607195c1938c7bc4232ce73ba75267 100644 (file)
@@ -69,7 +69,7 @@ extern void SST_GetFrequencyRange(SST_Stats inst, double *lo, double *hi);
 /* Get data needed for selection */
 extern void
 SST_GetSelectionData(SST_Stats inst, struct timespec *now,
-                     int *stratum, NTP_Leap *leap,
+                     int *stratum,
                      double *offset_lo_limit,
                      double *offset_hi_limit,
                      double *root_distance,