SRC_UpdateReachability(inst->source, 1);
SRC_AccumulateSample(inst->source, &sample_time, offset,
inst->delay, dispersion, inst->delay, dispersion, stratum, inst->leap_status);
+ SRC_SelectSource(inst->source);
log_sample(inst, &sample_time, 1, 0, 0.0, offset, dispersion);
} else {
IS FLIPPED */
SST_AccumulateSample(inst->stats, sample_time, -offset, peer_delay, peer_dispersion, root_delay, root_dispersion, stratum);
SST_DoNewRegression(inst->stats);
- /* And redo clock selection */
- SRC_SelectSource(inst->ref_id);
}
/* ================================================== */
/* If this was the previous reference source, we have to reselect! */
if (inst->index == selected_source_index) {
- SRC_SelectSource(0);
+ SRC_SelectSource(NULL);
}
}
if (!reachable && inst->index == selected_source_index) {
/* Try to select a better source */
- SRC_SelectSource(0);
+ SRC_SelectSource(NULL);
}
}
or match_refid is equal to the selected reference source refid */
void
-SRC_SelectSource(uint32_t match_refid)
+SRC_SelectSource(SRC_Instance updated_inst)
{
int i, j, index, old_selected_index, sel_prefer;
struct timeval now, ref_time;
/* Update score, but only for source pairs where one source
has a new sample */
- if (sources[i]->ref_id == match_refid ||
- sources[selected_source_index]->ref_id == match_refid) {
+ if (sources[i] == updated_inst ||
+ sources[selected_source_index] == updated_inst) {
sources[i]->sel_score *= sel_src_distance / distance;
}
#if 0
- LOG(LOGS_INFO, LOGF_Sources, "select score=%f refid=%lx match_refid=%lx status=%d dist=%f",
- sources[i]->sel_score, sources[i]->ref_id, match_refid, sources[i]->status, distance);
+ LOG(LOGS_INFO, LOGF_Sources, "select score=%f refid=%x match_refid=%x status=%d dist=%f",
+ sources[i]->sel_score, sources[i]->ref_id, updated_inst ? updated_inst->ref_id : 0,
+ sources[i]->status, distance);
#endif
if (max_score < sources[i]->sel_score) {
sources[selected_source_index]->status = SRC_SYNC;
- /* Update local reference only when a new source was selected or a new
- sample was received (i.e. match_refid is equal to selected refid) */
+ /* Update local reference only when a new source was selected
+ or the selected source has a new sample */
if (selected_source_index != old_selected_index ||
- match_refid == sources[selected_source_index]->ref_id) {
+ updated_inst == sources[selected_source_index]) {
/* Now just use the statistics of the selected source combined with
the other selectable sources for trimming the local clock */
SRC_ReselectSource(void)
{
selected_source_index = INVALID_SOURCE;
- SRC_SelectSource(0);
+ SRC_SelectSource(NULL);
}
/* ================================================== */
/* This routine is used to select the best source from amongst those
we currently have valid data on, and use it as the tracking base
for the local time. Updates are only made to the local reference
- if a new source is selected or match_addr is equal to the selected
- reference source address. (This avoids updating the frequency
+ if a new source is selected or updated_inst is the selected
+ reference source. (This avoids updating the frequency
tracking for every sample from other sources - only the ones from
the selected reference make a difference) */
-extern void SRC_SelectSource(uint32_t match_refid);
+extern void SRC_SelectSource(SRC_Instance updated_inst);
/* Force reselecting the best source */
extern void SRC_ReselectSource(void);