From: Harlan Stenn Date: Fri, 23 Nov 2007 09:34:06 +0000 (-0500) Subject: Dave Mills shifted some orphan processing X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8abf9dc3532b3962256da696badf0f4bbd206c28;p=thirdparty%2Fntp.git Dave Mills shifted some orphan processing bk: 47469e8eTpx95_giTEsBZH75Ap6osQ --- diff --git a/ChangeLog b/ChangeLog index 251101d8f6..7b1dd04a71 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ +* Dave Mills shifted some orphan processing. * Fix typos in the [Bug 963] patch. * bootstrap: squawk if genver fails. Use -f with cp in case Dave does a chown. * Remove obsolete simulator command-line options. diff --git a/include/ntpd.h b/include/ntpd.h index bf63cb93ac..c082d05ee7 100644 --- a/include/ntpd.h +++ b/include/ntpd.h @@ -188,6 +188,9 @@ extern void kod_proto (void); extern int leap_tai; extern u_long leap_expire; extern u_long leap_sec; +extern int sys_orphan; +extern double sys_mindisp; +extern double sys_maxdist; /* * there seems to be a bug in the IRIX 4 compiler which prevents diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c index 6b58804833..d88c2931ba 100644 --- a/ntpd/ntp_proto.c +++ b/ntpd/ntp_proto.c @@ -85,8 +85,8 @@ int sys_authenticate; /* requre authentication for config */ l_fp sys_authdelay; /* authentication delay */ static double sys_offset; /* current local clock offset */ static u_long sys_authdly[2]; /* authentication delay shift reg */ -static double sys_mindisp = MINDISPERSE; /* min disp increment (s) */ -static double sys_maxdist = MAXDISTANCE; /* selection threshold */ +double sys_mindisp = MINDISPERSE; /* min disp increment (s) */ +double sys_maxdist = MAXDISTANCE; /* selection threshold */ double sys_jitter; /* system jitter */ u_long sys_epoch; /* last clock update time */ static int sys_hopper; /* anticlockhop counter */ @@ -155,22 +155,7 @@ transmit( * server modes) and those that do (all other modes). The dance * is intricate... */ - /* - * Orphan mode is active when enabled and when no servers less - * than the orphan statum are available. A server with no other - * synchronization source is an orphan It shows offset zero and - * reference ID the loopback address. - */ hpoll = peer->hpoll; - if (sys_orphan < STRATUM_UNSPEC && sys_peer == NULL) { - sys_leap = LEAP_NOWARNING; - sys_stratum = sys_orphan; - sys_refid = htonl(LOOPBACKADR); - sys_rootdelay = 0; - sys_rootdisp = sys_mindisp; - sys_offset = 0; - } - /* * In broadcast mode the poll interval is never changed from * minpoll. diff --git a/ntpd/ntp_timer.c b/ntpd/ntp_timer.c index 63b63e1daf..5cbeb3c945 100644 --- a/ntpd/ntp_timer.c +++ b/ntpd/ntp_timer.c @@ -323,6 +323,24 @@ timer(void) } } + /* + * Orphan mode is active when enabled and when no servers less + * than the orphan statum are available. A server with no other + * synchronization source is an orphan It shows offset zero and + * reference ID the loopback address. + */ + if (sys_orphan < STRATUM_UNSPEC && sys_peer == NULL) { + if (sys_leap == LEAP_NOTINSYNC) + sys_leap = LEAP_NOWARNING; + sys_stratum = sys_orphan; + if (sys_stratum > 1) + sys_refid = htonl(LOOPBACKADR); + else + memcpy(&sys_refid, "LOOP", 4); + sys_rootdelay = 0; + sys_rootdisp = sys_mindisp; + } + /* * Leapseconds. When the time remaining decrements to zero, * increment the TAI offset. If the kernel code is not available