]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 3583] synchronization error
authorJuergen Perlinger <perlinger@ntp.org>
Sat, 27 Apr 2019 16:55:23 +0000 (18:55 +0200)
committerJuergen Perlinger <perlinger@ntp.org>
Sat, 27 Apr 2019 16:55:23 +0000 (18:55 +0200)
bk: 5cc4897bbO_nj6Pn9x6u8uCrywhN-w

ChangeLog
libntp/systime.c

index 9ff845c81028eeecbd72fd587d28555bc5f781e5..1343d7859682c5db6819d369f78bfddbda0baef8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+---
+* [Bug 3583] synchronization error <perlinger@ntp.org>
+  - set clock to base date if system time is before that limit
+
 ---
 (4.2.8p13) 2019/03/07 Released by Harlan Stenn <stenn@ntp.org>
 
index 8e70897466cb2884007d6cfc7f6c0485da56fa2c..a738c8d924dd0e6bd1a12376f9c2c4c8c630aeff 100644 (file)
@@ -619,12 +619,11 @@ clamp_systime(void)
 {
 #if SIZEOF_TIME_T > 4
 
-       struct timeval timetv, tvlast;
+       struct timeval  tvbase, tvlast;
        struct timespec timets;
-       uint32_t        tdiff;
-
        
-       timetv.tv_sec = basedate_get_erabase();
+       tvbase.tv_sec  = basedate_get_erabase();
+       tvbase.tv_usec = 0;
        
        /* ---> time-critical path starts ---> */
 
@@ -636,28 +635,24 @@ clamp_systime(void)
                tvlast.tv_usec -= 1000000;
                tvlast.tv_sec  += 1;
        }
-       timetv.tv_usec = tvlast.tv_usec;
 
-       tdiff = (uint32_t)(tvlast.tv_sec & UINT32_MAX) -
-               (uint32_t)(timetv.tv_sec & UINT32_MAX);
-       timetv.tv_sec += tdiff;
-       if (timetv.tv_sec != tvlast.tv_sec) {
+       if (tvbase.tv_sec > tvlast.tv_sec) {
                /* now set new system time */
-               if (ntp_set_tod(&timetv, NULL) != 0) {
+               if (ntp_set_tod(&tvbase, NULL) != 0) {
                        msyslog(LOG_ERR, "clamp-systime: %m");
                        return FALSE;
                }
        } else {
                msyslog(LOG_INFO,
                        "clamp-systime: clock (%s) in allowed range",
-                       tv_fmt_libbuf(&timetv));
+                       tv_fmt_libbuf(&tvlast));
                return FALSE;
        }
 
        /* <--- time-critical path ended with 'ntp_set_tod()' <--- */
 
        sys_residual = 0;
-       lamport_violated = (timetv.tv_sec < tvlast.tv_sec);
+       lamport_violated = (tvbase.tv_sec < tvlast.tv_sec);
        if (step_callback)
                (*step_callback)();
 
@@ -668,15 +663,16 @@ clamp_systime(void)
        _clear_adjtime();
 #   endif
 
-       update_uwtmp(timetv, tvlast);
+       update_uwtmp(tvbase, tvlast);
        msyslog(LOG_WARNING,
                "clamp-systime: clock stepped from %s to %s!",
-               tv_fmt_libbuf(&tvlast), tv_fmt_libbuf(&timetv));
+               tv_fmt_libbuf(&tvlast), tv_fmt_libbuf(&tvbase));
        return TRUE;
                
 #else
 
-       return 0;
+       return FALSE;
+       
 #endif
 }