]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2473] NTPD exits after clock is stepped backwards externally
authorJuergen Perlinger <perlinger@ntp.org>
Sun, 1 Sep 2013 08:34:32 +0000 (10:34 +0200)
committerJuergen Perlinger <perlinger@ntp.org>
Sun, 1 Sep 2013 08:34:32 +0000 (10:34 +0200)
bk: 5222fc18X8S_S2T9c7ZtYpRxFeJk3g

ChangeLog
libntp/systime.c

index 9ebb9dc054c10c779068c069a32cd3027e5f0d90..4b7399f18fa2e105a8cc638b8c5eff6a9172d951 100644 (file)
--- 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 <stenn@ntp.org>
 * CID 975596: Copy/paste error: vallen should be siglen.
 * CID 1009579: Check return status of X509_add_ext().
index 5264b9e127c0c3482e064fcda20d943eb30e7c7e..e8583c5439d5f96e796fccf3871cb1e35d7f3698 100644 (file)
@@ -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