From: Miroslav Lichvar Date: Fri, 8 Mar 2013 12:54:10 +0000 (+0100) Subject: Fix delta calculation with extreme frequency offsets X-Git-Tag: 1.28-pre1~92 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=0bb772c575b3842c38e6a58591ecea94449e9bae;p=thirdparty%2Fchrony.git Fix delta calculation with extreme frequency offsets This should prevent chronyd from getting stuck and refusing new samples due to failing test4 when the current measured frequency offset is close to 1.0. That can happen when the system clock is stepped forward behind chronyd's back. --- diff --git a/ntp_core.c b/ntp_core.c index 0fb93e17..be9f613d 100644 --- a/ntp_core.c +++ b/ntp_core.c @@ -793,7 +793,7 @@ receive_packet(NTP_Packet *message, struct timeval *now, double now_err, NCR_Ins assuming worst case frequency error between us and the other source */ - delta = local_interval - remote_interval / (1.0 - source_freq_lo); + delta = local_interval - remote_interval * (1.0 + source_freq_lo); /* Calculate theta. Following the NTP definition, this is negative if we are fast of the remote source. */