From: Miroslav Lichvar Date: Thu, 13 Jun 2013 16:19:17 +0000 (+0200) Subject: Don't apply outlyer penalty at beginning X-Git-Tag: 1.28-pre1~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ad22e9a024ec0ed67214b16e382d958a0189c33;p=thirdparty%2Fchrony.git Don't apply outlyer penalty at beginning Wait until the reach register is full to allow marking a source as outlyer for 32 updates. This makes start nicer with iburst. --- diff --git a/sources.c b/sources.c index 2cb1ec41..dd201205 100644 --- a/sources.c +++ b/sources.c @@ -93,6 +93,9 @@ struct SRC_Instance_Record { /* Reachability register */ int reachability; + /* Flag indicating that only few samples were accumulated so far */ + int beginning; + /* Updates left before resetting outlyer status */ int outlyer; @@ -216,6 +219,7 @@ SRC_Instance SRC_CreateNewInstance(uint32_t ref_id, SRC_Type type, SRC_SelectOpt result->ip_addr = addr; result->selectable = 0; result->reachability = 0; + result->beginning = 1; result->outlyer = 0; result->status = SRC_BAD_STATS; result->type = type; @@ -360,6 +364,10 @@ SRC_UpdateReachability(SRC_Instance inst, int reachable) inst->reachability |= !!reachable; inst->reachability &= ~(-1 << REACH_BITS); + /* The beginning is over when the first sample is at the end of the register */ + if (inst->reachability & (1 << (REACH_BITS - 1))) + inst->beginning = 0; + if (!reachable && inst->index == selected_source_index) { /* Try to select a better source */ SRC_SelectSource(0); @@ -446,7 +454,7 @@ combine_sources(int n_sel_sources, struct timeval *ref_time, double *offset, (reselect_distance + sources[selected_source_index]->sel_info.root_distance) || fabs(*frequency - src_frequency) > combine_limit * (*skew + src_skew + LCL_GetMaxClockError()))) { - sources[index]->outlyer = OUTLYER_PENALTY; + sources[index]->outlyer = !sources[index]->beginning ? OUTLYER_PENALTY : 1; } if (sources[index]->outlyer) {