]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Only fuzz the time after we know sys_precision (gettimeofday only)
authorHarlan Stenn <stenn@ntp.org>
Sat, 18 Feb 2006 04:50:33 +0000 (23:50 -0500)
committerHarlan Stenn <stenn@ntp.org>
Sat, 18 Feb 2006 04:50:33 +0000 (23:50 -0500)
bk: 43f6a799NOzMrZGDBW6R1qzgPUXIvg

libntp/systime.c

index 711a540089b6f96a8e142fbaa0d2134f74cd196d..05f47c65c7841716e3f2c08a197da0f09c596b53 100644 (file)
@@ -81,8 +81,16 @@ get_systime(
         */
        GETTIMEOFDAY(&tv, NULL);
        now->l_i = tv.tv_sec + JAN_1970;
-       /* ntp_random() produces 31 bits (always nonnegative) */
-       dtemp = (tv.tv_usec + ntp_random() / FRAC - .5) / 1e6;
+       dtemp = ts.tv_nsec / 1e6;
+
+       /*
+        * ntp_random() produces 31 bits (always nonnegative.
+        * This bit is done only after the precision has been
+        * determined.
+        */
+       if (sys_precision != 0)
+               dtemp += (ntp_random() / FRAC - .5) / (1 <<
+                   -sys_precision);
 
 #endif /* HAVE_CLOCK_GETTIME || HAVE_GETCLOCK */