From: Juergen Perlinger Date: Sun, 1 Sep 2013 08:34:32 +0000 (+0200) Subject: [Bug 2473] NTPD exits after clock is stepped backwards externally X-Git-Tag: NTP_4_2_7P388~1^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c48479dbffd2807ac1a8e54ce2c8629d4a19d67;p=thirdparty%2Fntp.git [Bug 2473] NTPD exits after clock is stepped backwards externally bk: 5222fc18X8S_S2T9c7ZtYpRxFeJk3g --- diff --git a/ChangeLog b/ChangeLog index 9ebb9dc05..4b7399f18 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ +* [Bug 2473] NTPD exits after clock is stepped backwards externally (4.2.7p385) 2013/08/19 Released by Harlan Stenn * CID 975596: Copy/paste error: vallen should be siglen. * CID 1009579: Check return status of X509_add_ext(). diff --git a/libntp/systime.c b/libntp/systime.c index 5264b9e12..e8583c543 100644 --- a/libntp/systime.c +++ b/libntp/systime.c @@ -158,6 +158,7 @@ get_systime( l_fp *now /* system time */ ) { + static struct timespec ts_last; /* last sampled os time */ static struct timespec ts_prev; /* prior os time */ static l_fp lfp_prev; /* prior result */ static double dfuzz_prev; /* prior fuzz */ @@ -175,6 +176,15 @@ get_systime( DEBUG_REQUIRE(systime_init_done); ENTER_GET_SYSTIME_CRITSEC(); + /* First check if here was a Lamport violation, that is, two + * successive calls to 'get_ostime()' resulted in negative + * time difference. Use a few milliseconds of permissible + * tolerance -- being too sharp can hurt here. + */ + if (cmp_tspec(ts, sub_tspec_ns(ts_last, 50000000)) < 0) + lamport_violated = 1; + ts_last = ts; + /* * After default_get_precision() has set a nonzero sys_fuzz, * ensure every reading of the OS clock advances by at least