sources: replace beginning flag with size of reachability register
This will allow to detect sources that are not reachable on start.
This commit is contained in:
parent
0094128ca6
commit
4932f9d077
1 changed files with 9 additions and 7 deletions
16
sources.c
16
sources.c
|
@ -93,8 +93,8 @@ struct SRC_Instance_Record {
|
||||||
/* Reachability register */
|
/* Reachability register */
|
||||||
int reachability;
|
int reachability;
|
||||||
|
|
||||||
/* Flag indicating that only few samples were accumulated so far */
|
/* Number of set bits in the reachability register */
|
||||||
int beginning;
|
int reachability_size;
|
||||||
|
|
||||||
/* Updates left before allowing combining */
|
/* Updates left before allowing combining */
|
||||||
int outlier;
|
int outlier;
|
||||||
|
@ -219,7 +219,7 @@ SRC_Instance SRC_CreateNewInstance(uint32_t ref_id, SRC_Type type, SRC_SelectOpt
|
||||||
result->ip_addr = addr;
|
result->ip_addr = addr;
|
||||||
result->selectable = 0;
|
result->selectable = 0;
|
||||||
result->reachability = 0;
|
result->reachability = 0;
|
||||||
result->beginning = 1;
|
result->reachability_size = 0;
|
||||||
result->outlier = 0;
|
result->outlier = 0;
|
||||||
result->status = SRC_BAD_STATS;
|
result->status = SRC_BAD_STATS;
|
||||||
result->type = type;
|
result->type = type;
|
||||||
|
@ -356,9 +356,8 @@ SRC_UpdateReachability(SRC_Instance inst, int reachable)
|
||||||
inst->reachability |= !!reachable;
|
inst->reachability |= !!reachable;
|
||||||
inst->reachability &= ~(-1 << REACH_BITS);
|
inst->reachability &= ~(-1 << REACH_BITS);
|
||||||
|
|
||||||
/* The beginning is over when the first sample is at the end of the register */
|
if (inst->reachability_size < REACH_BITS)
|
||||||
if (inst->reachability & (1 << (REACH_BITS - 1)))
|
inst->reachability_size++;
|
||||||
inst->beginning = 0;
|
|
||||||
|
|
||||||
if (!reachable && inst->index == selected_source_index) {
|
if (!reachable && inst->index == selected_source_index) {
|
||||||
/* Try to select a better source */
|
/* Try to select a better source */
|
||||||
|
@ -375,6 +374,7 @@ SRC_ResetReachability(SRC_Instance inst)
|
||||||
a peer selected even when not reachable */
|
a peer selected even when not reachable */
|
||||||
#if 0
|
#if 0
|
||||||
inst->reachability = 0;
|
inst->reachability = 0;
|
||||||
|
inst->reachability_size = 0;
|
||||||
SRC_UpdateReachability(inst, 0);
|
SRC_UpdateReachability(inst, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -451,7 +451,9 @@ combine_sources(int n_sel_sources, struct timeval *ref_time, double *offset,
|
||||||
(reselect_distance + sources[selected_source_index]->sel_info.root_distance) ||
|
(reselect_distance + sources[selected_source_index]->sel_info.root_distance) ||
|
||||||
fabs(*frequency - src_frequency) >
|
fabs(*frequency - src_frequency) >
|
||||||
combine_limit * (*skew + src_skew + LCL_GetMaxClockError()))) {
|
combine_limit * (*skew + src_skew + LCL_GetMaxClockError()))) {
|
||||||
sources[index]->outlier = !sources[index]->beginning ? OUTLIER_PENALTY : 1;
|
/* Use a smaller penalty in first few updates */
|
||||||
|
sources[index]->outlier = sources[index]->reachability_size >= REACH_BITS ?
|
||||||
|
OUTLIER_PENALTY : 1;
|
||||||
} else if (sources[index]->outlier) {
|
} else if (sources[index]->outlier) {
|
||||||
sources[index]->outlier--;
|
sources[index]->outlier--;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue