From: Harlan Stenn Date: Wed, 6 May 2009 06:47:31 +0000 (-0400) Subject: [Bug 1175] Instability in PLL daemon mode X-Git-Tag: NTP_4_2_5P172~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=713146e8424839571fc7489eef8f45d6535867f9;p=thirdparty%2Fntp.git [Bug 1175] Instability in PLL daemon mode bk: 4a013283-ePPwHkLkak2zlkOGX0O1w --- diff --git a/ChangeLog b/ChangeLog index 5c18aaf82..b9e46f51c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,5 @@ -* [Bug 1176] refclock_parse.c does not compile without PPSAPI +* [Bug 1175] Instability in PLL daemon mode. +* [Bug 1176] refclock_parse.c does not compile without PPSAPI. (4.2.5p171) 2009/05/04 Released by Harlan Stenn * Autokey documentation cleanup from Dave Mills. * [Bug 1171] line editing libs found without headers (Solaris 11) diff --git a/include/Makefile.am b/include/Makefile.am index d183f6e4a..3fbc822c7 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -5,63 +5,65 @@ EXTRA_DIST = autogen-version.def copyright.def debug-opt.def homerc.def version. SUBDIRS = isc -noinst_HEADERS = \ - adjtime.h \ - audio.h \ - ascii.h \ - audio.h \ - binio.h \ - global.h \ - gps.h \ - hopf6039.h \ - icom.h \ - ieee754io.h \ - iosignal.h \ - l_stdlib.h \ - mbg_gps166.h \ - mx4200.h \ - ntif.h \ - ntp.h \ - ntp_assert.h \ - ntp_calendar.h \ - ntp_cmdargs.h \ - ntp_config.h \ - ntp_control.h \ - ntp_crypto.h \ - ntp_data_structures.h \ - ntp_datum.h \ - ntp_debug.h \ - ntp_filegen.h \ - ntp_fp.h \ - ntp_if.h \ - ntp_io.h \ - ntp_lineedit.h - ntp_machine.h \ - ntp_malloc.h \ - ntp_md5.h \ - ntp_net.h \ - ntp_proto.h \ - ntp_random.h \ - ntp_refclock.h \ - ntp_request.h \ - ntp_rfc2553.h \ - ntp_select.h \ - ntp_sprintf.h \ - ntp_stdlib.h \ - ntp_string.h \ - ntp_syscall.h \ - ntp_syslog.h \ - ntp_tty.h \ - ntp_types.h \ - ntp_unixtime.h \ - ntpd.h \ - ntpsim.h \ - parse.h \ - parse_conf.h \ - recvbuff.h \ +NULL= +noinst_HEADERS = \ + adjtime.h \ + audio.h \ + ascii.h \ + audio.h \ + binio.h \ + global.h \ + gps.h \ + hopf6039.h \ + icom.h \ + ieee754io.h \ + iosignal.h \ + l_stdlib.h \ + mbg_gps166.h \ + mx4200.h \ + ntif.h \ + ntp.h \ + ntp_assert.h \ + ntp_calendar.h \ + ntp_cmdargs.h \ + ntp_config.h \ + ntp_control.h \ + ntp_crypto.h \ + ntp_data_structures.h \ + ntp_datum.h \ + ntp_debug.h \ + ntp_filegen.h \ + ntp_fp.h \ + ntp_if.h \ + ntp_io.h \ + ntp_lineedit.h \ + ntp_machine.h \ + ntp_malloc.h \ + ntp_md5.h \ + ntp_net.h \ + ntp_proto.h \ + ntp_random.h \ + ntp_refclock.h \ + ntp_request.h \ + ntp_rfc2553.h \ + ntp_select.h \ + ntp_sprintf.h \ + ntp_stdlib.h \ + ntp_string.h \ + ntp_syscall.h \ + ntp_syslog.h \ + ntp_tty.h \ + ntp_types.h \ + ntp_unixtime.h \ + ntpd.h \ + ntpsim.h \ + parse.h \ + parse_conf.h \ + recvbuff.h \ refclock_atom.h \ timepps-SCO.h \ timepps-Solaris.h \ timepps-SunOS.h \ - trimble.h + trimble.h \ + $(NULL) diff --git a/include/ntpd.h b/include/ntpd.h index cfea97988..153be35eb 100644 --- a/include/ntpd.h +++ b/include/ntpd.h @@ -108,7 +108,7 @@ extern void block_io_and_alarm (void); /* ntp_loopfilter.c */ extern void init_loopfilter(void); -extern int local_clock(struct peer *, u_long, double); +extern int local_clock(struct peer *, double); extern void adj_host_clock(void); extern void loop_config(int, double); extern void huffpuff(void); diff --git a/ntpd/ntp_loopfilter.c b/ntpd/ntp_loopfilter.c index 79779bd6e..ad1c8c639 100644 --- a/ntpd/ntp_loopfilter.c +++ b/ntpd/ntp_loopfilter.c @@ -121,7 +121,7 @@ double clock_jitter; /* offset jitter */ double drift_comp; /* frequency (s/s) */ double clock_stability; /* frequency stability (wander) (s/s) */ double clock_codec; /* audio codec frequency (samples/s) */ -u_long clock_epoch; /* interval since last update */ +static u_long clock_epoch; /* last update */ u_int sys_tai; /* TAI offset from UTC */ static void rstclock (int, double); /* transition function */ static double direct_freq(double); /* direct set frequency */ @@ -204,12 +204,12 @@ init_loopfilter(void) int local_clock( struct peer *peer, /* synch source peer structure */ - u_long mu, /* measurement interval */ double fp_offset /* clock offset (s) */ ) { int rval; /* return code */ int osys_poll; /* old system poll */ + double mu; /* interval since last update */ double clock_frequency; /* clock frequency */ double dtemp, etemp; /* double temps */ char tbuf[80]; /* report buffer */ @@ -316,7 +316,7 @@ local_clock( sys_poll = peer->minpoll; if (sys_poll > peer->maxpoll) sys_poll = peer->maxpoll; - clock_epoch += mu; + mu = current_time - clock_epoch; clock_frequency = drift_comp; rval = 1; if (fabs(fp_offset) > clock_max && clock_max > 0) { @@ -339,7 +339,7 @@ local_clock( * the apparent frequency correction and step the phase. */ case EVNT_FREQ: - if (clock_epoch < clock_minstep) + if (mu < clock_minstep) return (0); clock_frequency = direct_freq(fp_offset); @@ -352,7 +352,7 @@ local_clock( * exceeded. */ case EVNT_SPIK: - if (clock_epoch < clock_minstep) + if (mu < clock_minstep) return (0); /* fall through to default */ @@ -440,7 +440,7 @@ local_clock( * update. */ case EVNT_FREQ: - if (clock_epoch < clock_minstep) + if (mu < clock_minstep) return (0); clock_frequency = direct_freq(fp_offset); @@ -466,8 +466,8 @@ local_clock( if (sys_poll >= allan_xpt) clock_frequency += (fp_offset - clock_offset) / - max(ULOGTOD(sys_poll), - clock_epoch) * CLOCK_FLL; + max(ULOGTOD(sys_poll), mu) * + CLOCK_FLL; /* * The PLL frequency gain (numerator) depends on @@ -475,7 +475,7 @@ local_clock( * intercept. This reduces the PLL gain when the * FLL becomes effective. */ - etemp = min(ULOGTOD(allan_xpt), clock_epoch); + etemp = min(ULOGTOD(allan_xpt), mu); dtemp = 4 * CLOCK_PLL * ULOGTOD(sys_poll); clock_frequency += fp_offset * etemp / (dtemp * dtemp); @@ -734,13 +734,14 @@ rstclock( #ifdef DEBUG if (debug > 1) printf("local_clock: mu %lu state %d poll %d count %d\n", - clock_epoch, trans, sys_poll, tc_counter); + current_time - clock_epoch, trans, sys_poll, + tc_counter); #endif if (trans != state && trans != EVNT_FSET) report_event(trans, NULL, NULL); state = trans; last_offset = clock_offset = offset; - clock_epoch = 0; + clock_epoch = current_time; } /* @@ -776,7 +777,8 @@ direct_freq( drift_comp = FREQTOD(ntv.freq); } #endif /* KERNEL_PLL */ - set_freq((fp_offset - clock_offset) / clock_epoch + drift_comp); + set_freq((fp_offset - clock_offset) / (current_time - + clock_epoch) + drift_comp); wander_resid = 0; return (drift_comp); } diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c index e5f406b73..5a1a6e6fc 100644 --- a/ntpd/ntp_proto.c +++ b/ntpd/ntp_proto.c @@ -1674,7 +1674,7 @@ clock_update( * Comes now the moment of truth. Crank the clock discipline and * see what comes out. */ - switch (local_clock(peer, peer->epoch, sys_offset)) { + switch (local_clock(peer, sys_offset)) { /* * Clock exceeds panic threshold. Life as we know it ends.