sourcestats: move leap status to sources

This commit is contained in:
Miroslav Lichvar 2020-03-11 15:21:57 +01:00
parent e7a254265f
commit ff9301567e
3 changed files with 10 additions and 12 deletions

View file

@ -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++;
}

View 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]));

View 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,