sourcestats: move leap status to sources
This commit is contained in:
parent
e7a254265f
commit
ff9301567e
3 changed files with 10 additions and 12 deletions
12
sources.c
12
sources.c
|
@ -54,7 +54,6 @@ static int initialised = 0;
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
/* Structure used to hold info for selecting between sources */
|
/* Structure used to hold info for selecting between sources */
|
||||||
struct SelectInfo {
|
struct SelectInfo {
|
||||||
NTP_Leap leap;
|
|
||||||
int stratum;
|
int stratum;
|
||||||
int select_ok;
|
int select_ok;
|
||||||
double std_dev;
|
double std_dev;
|
||||||
|
@ -126,6 +125,9 @@ struct SRC_Instance_Record {
|
||||||
double sel_score;
|
double sel_score;
|
||||||
|
|
||||||
struct SelectInfo sel_info;
|
struct SelectInfo sel_info;
|
||||||
|
|
||||||
|
/* Latest leap status */
|
||||||
|
NTP_Leap leap;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
@ -298,6 +300,7 @@ SRC_ResetInstance(SRC_Instance instance)
|
||||||
instance->distant = 0;
|
instance->distant = 0;
|
||||||
instance->status = SRC_BAD_STATS;
|
instance->status = SRC_BAD_STATS;
|
||||||
instance->sel_score = 1.0;
|
instance->sel_score = 1.0;
|
||||||
|
instance->leap = LEAP_Unsynchronised;
|
||||||
|
|
||||||
SST_ResetInstance(instance->stats);
|
SST_ResetInstance(instance->stats);
|
||||||
}
|
}
|
||||||
|
@ -348,6 +351,7 @@ SRC_AccumulateSample(SRC_Instance inst, NTP_Sample *sample)
|
||||||
|
|
||||||
SST_AccumulateSample(inst->stats, sample);
|
SST_AccumulateSample(inst->stats, sample);
|
||||||
SST_DoNewRegression(inst->stats);
|
SST_DoNewRegression(inst->stats);
|
||||||
|
inst->leap = sample->leap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
@ -642,7 +646,7 @@ SRC_SelectSource(SRC_Instance updated_inst)
|
||||||
}
|
}
|
||||||
|
|
||||||
si = &sources[i]->sel_info;
|
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->lo_limit, &si->hi_limit, &si->root_distance,
|
||||||
&si->std_dev, &first_sample_ago,
|
&si->std_dev, &first_sample_ago,
|
||||||
&si->last_sample_ago, &si->select_ok);
|
&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))
|
if (best_trust_depth && !(sources[index]->sel_options & SRC_SELECT_TRUST))
|
||||||
continue;
|
continue;
|
||||||
leap_votes++;
|
leap_votes++;
|
||||||
if (sources[index]->sel_info.leap == LEAP_InsertSecond)
|
if (sources[index]->leap == LEAP_InsertSecond)
|
||||||
leap_ins++;
|
leap_ins++;
|
||||||
else if (sources[index]->sel_info.leap == LEAP_DeleteSecond)
|
else if (sources[index]->leap == LEAP_DeleteSecond)
|
||||||
leap_del++;
|
leap_del++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,9 +180,6 @@ struct SST_Stats_Record {
|
||||||
|
|
||||||
/* The stratum from the last accumulated sample */
|
/* The stratum from the last accumulated sample */
|
||||||
int stratum;
|
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->nruns = 0;
|
||||||
inst->asymmetry_run = 0;
|
inst->asymmetry_run = 0;
|
||||||
inst->asymmetry = 0.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_delays[m] = sample->root_delay;
|
||||||
inst->root_dispersions[m] = sample->root_dispersion;
|
inst->root_dispersions[m] = sample->root_dispersion;
|
||||||
inst->stratum = sample->stratum;
|
inst->stratum = sample->stratum;
|
||||||
inst->leap = sample->leap;
|
|
||||||
|
|
||||||
if (inst->peer_delays[n] < inst->fixed_min_delay)
|
if (inst->peer_delays[n] < inst->fixed_min_delay)
|
||||||
inst->peer_delays[n] = 2.0 * inst->fixed_min_delay - inst->peer_delays[n];
|
inst->peer_delays[n] = 2.0 * inst->fixed_min_delay - inst->peer_delays[n];
|
||||||
|
@ -655,7 +650,7 @@ SST_GetFrequencyRange(SST_Stats inst,
|
||||||
|
|
||||||
void
|
void
|
||||||
SST_GetSelectionData(SST_Stats inst, struct timespec *now,
|
SST_GetSelectionData(SST_Stats inst, struct timespec *now,
|
||||||
int *stratum, NTP_Leap *leap,
|
int *stratum,
|
||||||
double *offset_lo_limit,
|
double *offset_lo_limit,
|
||||||
double *offset_hi_limit,
|
double *offset_hi_limit,
|
||||||
double *root_distance,
|
double *root_distance,
|
||||||
|
@ -676,7 +671,6 @@ SST_GetSelectionData(SST_Stats inst, struct timespec *now,
|
||||||
j = get_buf_index(inst, inst->best_single_sample);
|
j = get_buf_index(inst, inst->best_single_sample);
|
||||||
|
|
||||||
*stratum = inst->stratum;
|
*stratum = inst->stratum;
|
||||||
*leap = inst->leap;
|
|
||||||
*std_dev = inst->std_dev;
|
*std_dev = inst->std_dev;
|
||||||
|
|
||||||
sample_elapsed = fabs(UTI_DiffTimespecsToDouble(now, &inst->sample_times[i]));
|
sample_elapsed = fabs(UTI_DiffTimespecsToDouble(now, &inst->sample_times[i]));
|
||||||
|
|
|
@ -69,7 +69,7 @@ extern void SST_GetFrequencyRange(SST_Stats inst, double *lo, double *hi);
|
||||||
/* Get data needed for selection */
|
/* Get data needed for selection */
|
||||||
extern void
|
extern void
|
||||||
SST_GetSelectionData(SST_Stats inst, struct timespec *now,
|
SST_GetSelectionData(SST_Stats inst, struct timespec *now,
|
||||||
int *stratum, NTP_Leap *leap,
|
int *stratum,
|
||||||
double *offset_lo_limit,
|
double *offset_lo_limit,
|
||||||
double *offset_hi_limit,
|
double *offset_hi_limit,
|
||||||
double *root_distance,
|
double *root_distance,
|
||||||
|
|
Loading…
Reference in a new issue