From: Miroslav Lichvar Date: Mon, 18 Nov 2024 15:18:40 +0000 (+0100) Subject: ntp+hwclock: add margin to estimated delay quantiles X-Git-Tag: 4.7-pre1~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c92358e0413a9fcaddb66822eb5b09e2e4089b76;p=thirdparty%2Fchrony.git ntp+hwclock: add margin to estimated delay quantiles Extend the interval of accepted delays by half of the quantile minimum step in both directions to make room for floating-point errors in the quantile calculation and an error that will be intentionally added in the next commit. --- diff --git a/hwclock.c b/hwclock.c index c662dae3..e2f72e7a 100644 --- a/hwclock.c +++ b/hwclock.c @@ -199,8 +199,10 @@ HCL_ProcessReadings(HCL_Instance clock, int n_readings, struct timespec tss[][3] local_prec = LCL_GetSysPrecisionAsQuantum(); - low_delay = QNT_GetQuantile(clock->delay_quants, QNT_GetMinK(clock->delay_quants)); - high_delay = QNT_GetQuantile(clock->delay_quants, QNT_GetMaxK(clock->delay_quants)); + low_delay = QNT_GetQuantile(clock->delay_quants, QNT_GetMinK(clock->delay_quants)) - + QNT_GetMinStep(clock->delay_quants) / 2.0; + high_delay = QNT_GetQuantile(clock->delay_quants, QNT_GetMaxK(clock->delay_quants)) + + QNT_GetMinStep(clock->delay_quants) / 2.0; low_delay = MIN(low_delay, high_delay); high_delay = MAX(high_delay, low_delay + local_prec); diff --git a/ntp_core.c b/ntp_core.c index 29654138..e802e183 100644 --- a/ntp_core.c +++ b/ntp_core.c @@ -1742,7 +1742,7 @@ check_delay_quant(NCR_Instance inst, double delay) quant = QNT_GetQuantile(inst->delay_quant, QNT_GetMinK(inst->delay_quant)); - if (delay <= quant) + if (delay <= quant + QNT_GetMinStep(inst->delay_quant) / 2.0) return 1; DEBUG_LOG("maxdelayquant: delay=%e quant=%e", delay, quant);