]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Restore 4.2.6 clock_combine() weighting to ntp-dev, reverting
authorDave Hart <hart@ntp.org>
Sat, 26 Nov 2011 12:50:07 +0000 (12:50 +0000)
committerDave Hart <hart@ntp.org>
Sat, 26 Nov 2011 12:50:07 +0000 (12:50 +0000)
 to pre-4.2.7p70 logic and avoiding divide-by-zero (from Dave Mills).

bk: 4ed0e07fUNqauJbuVlO9UQV-UCZK2w

ChangeLog
ntpd/ntp_proto.c

index c84c915fa3e3e8fbb5c83ecaa57b30a5ede13180..3cbbe26f1edfcb2feb4ad353f81e79da5fec1ba9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,7 +7,9 @@
 * [Bug 2069] from 4.2.6p5-RC2: broadcastclient, multicastclient spin up
   duplicate ephemeral associations without broadcastdelay.
 * from 4.2.6p5-RC2: Exclude not-yet-determined sys_refid from use in
-  loopback TEST12 (from David Mills).  
+  loopback TEST12 (from Dave Mills).
+* Restore 4.2.6 clock_combine() weighting to ntp-dev, reverting to pre-
+  4.2.7p70 logic and avoiding divide-by-zero (from Dave Mills).
 (4.2.7p236) 2011/11/16 Released by Harlan Stenn <stenn@ntp.org>
 * Documentation updates from Dave Mills.
 (4.2.7p235) 2011/11/16 Released by Harlan Stenn <stenn@ntp.org>
index 8c77650a629d261e89e589ed1478735fc3fec03b..be6d78a0063e3315f64d8b04fb26bd1199be2fb4 100644 (file)
@@ -2903,9 +2903,6 @@ clock_select(void)
 }
 
 
-/*
- * clock_combine - compute system offset and jitter from selected peers
- */
 static void
 clock_combine(
        struct peer **peers,    /* survivor list */
@@ -2913,11 +2910,14 @@ clock_combine(
        )
 {
        int     i;
-       double  x, y, z, w;
+       double  d, x, y, z, w;
 
        y = z = w = 0;
        for (i = 0; i < npeers; i++) {
-               x = max(sys_maxdist - root_distance(peers[i]), sys_mindisp);
+               d = root_distance(peers[i]);
+               if (0. == d)
+                       d = 1e-6;       /* hart avoid div by 0 */
+               x = 1. / d;
                y += x;
                z += peers[i]->offset * x;
                w += SQUARE(peers[i]->offset - peers[0]->offset) * x;