]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1175] Instability in PLL daemon mode
authorHarlan Stenn <stenn@ntp.org>
Wed, 6 May 2009 06:47:31 +0000 (02:47 -0400)
committerHarlan Stenn <stenn@ntp.org>
Wed, 6 May 2009 06:47:31 +0000 (02:47 -0400)
bk: 4a013283-ePPwHkLkak2zlkOGX0O1w

ChangeLog
include/Makefile.am
include/ntpd.h
ntpd/ntp_loopfilter.c
ntpd/ntp_proto.c

index 5c18aaf828df46b00e494aed235ea4b21b39f2c9..b9e46f51c3c738c376099c07610c346acb0cc29f 100644 (file)
--- 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 <stenn@ntp.org>
 * Autokey documentation cleanup from Dave Mills.
 * [Bug 1171] line editing libs found without headers (Solaris 11)
index d183f6e4afdb9e179eaf50616785780ad7a1ece3..3fbc822c733330c9f76ea00598f8443442f84f39 100644 (file)
@@ -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)
 
index cfea97988a7cb6f2c4a9d2914e82dcd7ba51bc08..153be35ebbb27d51c3097ab00b4080d5dbef6c15 100644 (file)
@@ -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);
index 79779bd6e9984759aec59a71622e711dfa2b8241..ad1c8c639f8076be0e613e1131bc3c364e4adeb1 100644 (file)
@@ -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);
 }
index e5f406b739f1c1eb615b7ac2249e89fac156363a..5a1a6e6fcd43eec4d6654993be4fcb52db6917f1 100644 (file)
@@ -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.