From: Dave Hart Date: Sat, 26 Nov 2011 12:50:07 +0000 (+0000) Subject: Restore 4.2.6 clock_combine() weighting to ntp-dev, reverting X-Git-Tag: NTP_4_2_7P237~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e20a412409c26fdce0513d06dc5d156e28ad5204;p=thirdparty%2Fntp.git 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). bk: 4ed0e07fUNqauJbuVlO9UQV-UCZK2w --- diff --git a/ChangeLog b/ChangeLog index c84c915fa..3cbbe26f1 100644 --- 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 * Documentation updates from Dave Mills. (4.2.7p235) 2011/11/16 Released by Harlan Stenn diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c index 8c77650a6..be6d78a00 100644 --- a/ntpd/ntp_proto.c +++ b/ntpd/ntp_proto.c @@ -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;