]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
ntp_loopfilter.c, ntpd.h, ChangeLog, ntp_proto.c:
authorHarlan Stenn <stenn@ntp.org>
Tue, 26 Oct 2010 21:20:17 +0000 (17:20 -0400)
committerHarlan Stenn <stenn@ntp.org>
Tue, 26 Oct 2010 21:20:17 +0000 (17:20 -0400)
  * [Bug 1680] Fix alignment of clock_select() arrays.
  * refinements to new startup behavior from David Mills.

bk: 4cc74611bFENCivttV2cNDPTZOf0nA

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

index fc430a2e8b32b24811e1e4013382b3487fd93f70..831a3a54ba3a706a753823224fbf2fe109a3cd59 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,5 @@
+* [Bug 1680] Fix alignment of clock_select() arrays.
+* refinements to new startup behavior from David Mills.
 * For the bootstrap script, touch .html files last.
 (4.2.7p72) 2010/10/26 Released by Harlan Stenn <stenn@ntp.org>
 * [Bug 1679] Fix test for -lsocket.
index 210d24bda11637821cdfaae473e44bb427b5b9ca..a33b3e69dadfbcfd290ef309b779c366c919ced4 100644 (file)
@@ -162,6 +162,7 @@ extern      void    loop_config(int, double);
 extern void    huffpuff(void);
 extern u_long  sys_clocktime;
 extern u_int   sys_tai;
+extern         int     freq_cnt;
 
 /* ntp_monitor.c */
 #define MON_HASH_SIZE          (1U << mon_hash_bits)
index aac517707bac689db803fb46fee9e2319c66eca8..461426fe8640be562091c7daced9f3cbaa1d3790 100644 (file)
@@ -185,6 +185,7 @@ init_loopfilter(void)
         */
        sys_poll = ntp_minpoll;
        clock_jitter = LOGTOD(sys_precision);
+       freq_cnt = clock_minstep;
 }
 
 /*
@@ -417,7 +418,6 @@ local_clock(
                 * the stepout threshold.
                 */
                case EVNT_NSET:
-                       freq_cnt = clock_minstep;
                        rstclock(EVNT_FREQ, fp_offset);
                        break;
 
@@ -428,7 +428,6 @@ local_clock(
                 * counter decrements to zero.
                 */
                case EVNT_FSET:
-                       freq_cnt = clock_minstep;
                        rstclock(EVNT_SYNC, fp_offset);
                        break;
 
@@ -443,7 +442,6 @@ local_clock(
                                return (0);
 
                        clock_frequency = direct_freq(fp_offset);
-                       freq_cnt = clock_minstep;
                        rstclock(EVNT_SYNC, 0);
                        /* fall through to default */
 
@@ -706,11 +704,12 @@ adj_host_clock(
         * time constant is clamkped at 2.
         */
        sys_rootdisp += clock_phi;
-       if (fabs(clock_offset) < CLOCK_FLOOR)
-               freq_cnt = 0;
-       else if (freq_cnt > 0 && sys_leap != LEAP_NOTINSYNC)
-               freq_cnt--;
-
+       if (state == EVNT_SYNC) {
+               if (fabs(clock_offset) < CLOCK_FLOOR)
+                       freq_cnt = 0;
+               else if (freq_cnt > 0)
+                       freq_cnt--;
+       }
 #ifndef LOCKCLOCK
        /*
         * If clock discipline is disabled or if the kernel is enabled,
@@ -727,7 +726,7 @@ adj_host_clock(
         * reduced time constant at startup.
         */
        if (freq_cnt > 0)
-               adjustment = clock_offset / (CLOCK_PLL * 4);
+               adjustment = clock_offset / (CLOCK_PLL * ULOGTOD(1));
        else
                adjustment = clock_offset / (CLOCK_PLL * ULOGTOD(sys_poll));
        clock_offset -= adjustment;
index b172da427180d14a946af40de93f5b24914c7494..a0ba8ad73ca33d97fee4eabbd4c8f1f6cd1f48fb 100644 (file)
@@ -2127,9 +2127,9 @@ clock_filter(
        }
 
        /*
-        * If the clock is synchronized,sort the samples by distance.  
+        * If the clock has stabilized, sort the samples by distance.  
         */
-       if (sys_leap != LEAP_NOTINSYNC) {
+       if (freq_cnt == 0) {
                for (i = 1; i < NTP_SHIFT; i++) {
                        for (j = 0; j < i; j++) {
                                if (dst[j] > dst[i]) {
@@ -2221,7 +2221,7 @@ clock_filter(
         */
        if (peer->filter_epoch[k] <= peer->epoch) {
 #if DEBUG
-       if (debug)
+       if (debug > 1)
                printf("clock_filter: old sample %lu\n", current_time -
                    peer->filter_epoch[k]);
 #endif
@@ -2278,15 +2278,15 @@ clock_select(void)
        struct peer *typepps = NULL;
 #endif /* REFCLOCK */
        static struct endpoint *endpoint = NULL;
-       static int *indx = NULL;
-       static struct peer **peers = NULL;
        static double *synch = NULL;
        static double *error = NULL;
+       static int *indx = NULL;
+       static struct peer **peers = NULL;
        static u_int endpoint_size = 0;
-       static u_int indx_size = 0;
-       static u_int peers_size = 0;
        static u_int synch_size = 0;
        static u_int error_size = 0;
+       static u_int peers_size = 0;
+       static u_int indx_size = 0;
        size_t octets;
 
        /*
@@ -2310,17 +2310,17 @@ clock_select(void)
        for (peer = peer_list; peer != NULL; peer = peer->p_link)
                nlist++;
        endpoint_size = nlist * 2 * sizeof(struct endpoint);
-       indx_size = nlist * 2 * sizeof(int);
-       peers_size = nlist * sizeof(struct peer *);
        synch_size = nlist * sizeof(double);
        error_size = nlist * sizeof(double);
+       peers_size = nlist * sizeof(struct peer *);
+       indx_size = nlist * 2 * sizeof(int);
        octets = endpoint_size + indx_size + peers_size + synch_size +
            error_size;
        endpoint = erealloc(endpoint, octets);
-       indx = (int *)((char *)endpoint + endpoint_size);
-       peers = (struct peer **)((char *)indx + indx_size);
-       synch = (double *)((char *)peers + peers_size);
+       synch = (double *)((char *)endpoint + endpoint_size);
        error = (double *)((char *)synch + synch_size);
+       peers = (struct peer **)((char *)error + error_size);
+       indx = (int *)((char *)peers + peers_size);
 
        /*
         * Initially, we populate the island with all the rifraff peers