]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Have sntp report synchronization distance instead of root dispersion
authorHarlan Stenn <stenn@ntp.org>
Sat, 20 Aug 2011 02:42:48 +0000 (02:42 +0000)
committerHarlan Stenn <stenn@ntp.org>
Sat, 20 Aug 2011 02:42:48 +0000 (02:42 +0000)
bk: 4e4f1f28Qwlp6_M3tF0nOksXmIezpQ

ChangeLog
scripts/ntp-wait-opts.def
sntp/main.c

index 086870ee0a015b7b6b091734886610e4c743a247..f0e8dcf209d5e0958be153c162fc702b1fff36b4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,5 @@
+* Have sntp report synchronization distance instead of root dispersion.
+* Clean up ntp-wait-opts.def .
 (4.2.7p205) 2011/08/19 Released by Harlan Stenn <stenn@ntp.org>
 * [Bug 1992] util/tg2 doesn't compile, needs libntp.
 (4.2.7p204) 2011/08/16 Released by Harlan Stenn <stenn@ntp.org>
index d5b7be16082689b936d22926c6e3f8bad93e1482..6e82d2198c42030a66c90aeeafa8ac0e0d0d9b83 100644 (file)
@@ -15,35 +15,33 @@ test-main;
 // #include       version.def
 
 flag = {
-    value     = n;
-    arg-type  = number;
-    arg-name  = num-tries;
-    descrip   = "Number of times to check ntpd";
-    doc = <<-  _EndOfDoc_
+  value                = n;
+  arg-type     = number;
+  arg-name     = "num-tries";
+  arg-default  = 100;
+  descrip      = "Number of times to check ntpd";
+  doc          = <<-  _EndOfDoc_
        The maximum number of times we will check ntpd to see if it
        has been able to synchronize and stabilize the system clock.
-
-       The default is 100 times.
        _EndOfDoc_;
 };
 
 flag = {
-    value     = s;
-    arg-type  = number;
-    arg-name  = secs-between-tries;
-    descrip   = "How long to sleep between tries";
-    doc = <<-  _EndOfDoc_
-       We will sleep for secs-between-tries after each query of ntpd
+  value                = s;
+  arg-type     = number;
+  arg-name     = "secs-between-tries";
+  arg-default  = 6;
+  descrip      = "How long to sleep between tries";
+  doc          = <<-  _EndOfDoc_
+       We will sleep for @file{secs-between-tries} after each query of ntpd
        that returns "the time is not yet stable".
-
-       The default is 6 seconds.
        _EndOfDoc_;
 };
 
 flag = {
-    value     = v;
-    descrip   = "Be verbose";
-    doc = <<-  _EndOfDoc_
+  value                = v;
+  descrip      = "Be verbose";
+  doc          = <<-  _EndOfDoc_
        By default, ntp-wait is silent.  With this option, ntp-wait
        will provide status information.
        _EndOfDoc_;
index 98cda4aed8bb7818b5cdc2c29b564fb374bcc592..5b1e11bcd95e2b7057f0af15ceb05495e90babcd 100644 (file)
@@ -1115,7 +1115,7 @@ handle_pkt(
        char *          ts_str;
        double          offset;
        double          precision;
-       double          root_dispersion;
+       double          synch_distance;
        char *          p_SNTP_PRETEND_TIME;
        time_t          pretend_time;
 #if SIZEOF_TIME_T == 8
@@ -1184,7 +1184,7 @@ handle_pkt(
                }
 
                offset_calculation(rpkt, rpktl, &tv_dst, &offset,
-                                  &precision, &root_dispersion);
+                                  &precision, &synch_distance);
                time_derived = TRUE;
 
                for (digits = 0; (precision *= 10.) < 1.; ++digits)
@@ -1197,9 +1197,9 @@ handle_pkt(
                if (0 == stratum)
                                stratum = 16;
 
-               if (root_dispersion > 0) {
+               if (synch_distance > 0) {
                        cnt = snprintf(disptxt, sizeof(disptxt),
-                                      " +/- %f", root_dispersion);
+                                      " +/- %f", synch_distance);
                        if (cnt >= sizeof(disptxt))
                                snprintf(disptxt, sizeof(disptxt),
                                         "ERROR %d >= %d", cnt,
@@ -1237,7 +1237,7 @@ offset_calculation(
        struct timeval *tv_dst,
        double *offset,
        double *precision,
-       double *root_dispersion
+       double *synch_distance
        )
 {
        l_fp p_rec, p_xmt, p_ref, p_org, tmp, dst;
@@ -1255,12 +1255,13 @@ offset_calculation(
        *precision = LOGTOD(rpkt->precision);
        TRACE(3, ("offset_calculation: precision: %f\n", *precision));
 
-       *root_dispersion = FPTOD(p_rdsp);
+       *synch_distance = (FPTOD(p_rdly) + FPTOD(p_rdsp))/2.0;
 
 #ifdef DEBUG
        if (debug > 2) {
                printf("sntp rootdelay: %f\n", FPTOD(p_rdly));
-               printf("sntp rootdisp: %f\n", *root_dispersion);
+               printf("sntp rootdisp: %f\n", FPTOD(p_rdsp));
+               printf("sntp syncdist: %f\n", *synch_distance);
 
                pkt_output(rpkt, rpktl, stdout);
 
@@ -1477,9 +1478,7 @@ gettimeofday_cached(
                        if (labs((long)diff.tv_sec) < 3600) {
                                /* older libevent2 using monotonic */
                                timeval_sub(&offset, &systemt, &mono);
-                               msyslog(LOG_NOTICE,
-                                       "Offsetting CLOCK_MONOTONIC times by %+ld.%06ld\n",
-                                       (long)offset.tv_sec, offset.tv_usec);
+                               TRACE(1, ("%s: Offsetting libevent CLOCK_MONOTONIC times by %.6f\n", progname, offset));
                        }
                }
                offset_ready = TRUE;