]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sourcestats: don't save stratum for all samples
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 1 Aug 2018 14:19:37 +0000 (16:19 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 3 Aug 2018 15:21:02 +0000 (17:21 +0200)
Save stratum only from the last accumulated sample as only that is
currently needed.

sourcestats.c

index 745026d60a4d19b8bf3e43ef4f0276abc755942e..0c1962473e8b4c293f80032a1045b8c9e5bbf467 100644 (file)
@@ -174,9 +174,8 @@ struct SST_Stats_Record {
      time of the measurements */
   double root_dispersions[MAX_SAMPLES];
 
-  /* This array contains the strata that were associated with the sources
-     at the times the samples were generated */
-  int strata[MAX_SAMPLES];
+  /* The stratum from the last accumulated sample */
+  int stratum;
 
   /* The leap status from the last accumulated sample */
   NTP_Leap leap;
@@ -323,7 +322,7 @@ SST_AccumulateSample(SST_Stats inst, struct timespec *sample_time,
   inst->peer_dispersions[m] = peer_dispersion;
   inst->root_delays[m] = root_delay;
   inst->root_dispersions[m] = root_dispersion;
-  inst->strata[m] = stratum;
+  inst->stratum = stratum;
   inst->leap = leap;
  
   if (inst->peer_delays[n] < inst->fixed_min_delay)
@@ -660,7 +659,7 @@ SST_GetSelectionData(SST_Stats inst, struct timespec *now,
   i = get_runsbuf_index(inst, inst->best_single_sample);
   j = get_buf_index(inst, inst->best_single_sample);
 
-  *stratum = inst->strata[get_buf_index(inst, inst->n_samples - 1)];
+  *stratum = inst->stratum;
   *leap = inst->leap;
   *std_dev = inst->std_dev;
 
@@ -869,7 +868,7 @@ SST_SaveToFile(SST_Stats inst, FILE *out)
             inst->root_delays[j],
             inst->root_dispersions[j],
             1.0, /* used to be inst->weights[i] */
-            inst->strata[j]);
+            inst->stratum /* used to be an array */);
 
   }
 
@@ -914,7 +913,7 @@ SST_LoadFromFile(SST_Stats inst, FILE *in)
                   &(inst->root_delays[i]),
                   &(inst->root_dispersions[i]),
                   &weight, /* not used anymore */
-                  &(inst->strata[i])) != 10)) {
+                  &inst->stratum) != 10)) {
 
         /* This is the branch taken if the read FAILED */
 
@@ -962,7 +961,7 @@ SST_DoSourceReport(SST_Stats inst, RPT_SourceReport *report, struct timespec *no
     report->orig_latest_meas = inst->orig_offsets[j];
     report->latest_meas = inst->offsets[i];
     report->latest_meas_err = 0.5*inst->root_delays[j] + inst->root_dispersions[j];
-    report->stratum = inst->strata[j];
+    report->stratum = inst->stratum;
 
     /* Align the sample time to reduce the leak of the receive timestamp */
     last_sample_time = inst->sample_times[i];