]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Lose peer_count from ntp_peer.c and ntp_proto.c (Dave Mills)
authorHarlan Stenn <stenn@ntp.org>
Tue, 12 Oct 2010 04:06:48 +0000 (00:06 -0400)
committerHarlan Stenn <stenn@ntp.org>
Tue, 12 Oct 2010 04:06:48 +0000 (00:06 -0400)
bk: 4cb3ded86qsAjsKy_6289NAEUqzBDA

ChangeLog
ntpd/ntp_peer.c
ntpd/ntp_proto.c

index fe4d0de849024d434ca0969c65d618c0aef6ddeb..5dacfc08036a0dff9c28feea6dc4e1b509c3e0d0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@
 * [Bug 1660] from 4.2.6p3-RC3: On some systems, test is in /usr/bin, not
   /bin. 
 * [Bug 1661] from 4.2.6p3-RC3: Re-indent refclock_ripencc.c.
+* Lose peer_count from ntp_peer.c and ntp_proto.c (Dave Mills).
 (4.2.7p61) 2010/10/06 Released by Harlan Stenn <stenn@ntp.org>
 * Documentation and code cleanup from Dave Mills. No more NTP_MAXASSOC.
 (4.2.7p60) 2010/10/04 Released by Harlan Stenn <stenn@ntp.org>
index f496a5fddd33fea1f1bb86e793aae6ecd61b9560..a95c2326c3fd49492649e8200076d200e871efb1 100644 (file)
@@ -85,7 +85,6 @@ struct peer *assoc_hash[NTP_HASH_SIZE];       /* association ID hash table */
 int    assoc_hash_count[NTP_HASH_SIZE];/* peers in each bucket */
 struct peer *peer_list;                        /* peer structures list */
 static struct peer *peer_free;         /* peer structures free list */
-int    peer_count;                     /* count of peer_list */
 int    peer_free_count;                /* count of free structures */
 
 /*
@@ -411,8 +410,7 @@ score(
 /*
  * free_peer - internal routine to free memory referred to by a struct
  *            peer and return it to the peer free list.  If unlink is
- *            nonzero, unlink from the various lists and decrement
- *            peer_count.
+ *            nonzero, unlink from the various lists.
  */
 static void
 free_peer(
@@ -456,8 +454,6 @@ free_peer(
                if (NULL == unlinked)
                        msyslog(LOG_ERR, "%s not in peer list!",
                                stoa(&p->srcadr));
-               else
-                       peer_count--;
        }
 
        if (p->hostname != NULL)
@@ -943,13 +939,10 @@ newpeer(
        LINK_SLIST(assoc_hash[hash], peer, aid_link);
        assoc_hash_count[hash]++;
        LINK_SLIST(peer_list, peer, p_link);
-       peer_count++;
 
        restrict_source(&peer->srcadr, 0, 0);
-
        snprintf(tbuf, sizeof(tbuf), "assoc %d", peer->associd);
        report_event(PEVNT_MOBIL, peer, tbuf);
-
        DPRINTF(1, ("newpeer: %s->%s mode %u vers %u poll %u %u flags 0x%x 0x%x ttl %u key %08x\n",
            latoa(peer->dstadr), stoa(&peer->srcadr), peer->hmode,
            peer->version, peer->minpoll, peer->maxpoll, peer->flags,
index 97b4109f538e9c9ddabee0147be7a8ec57ba0b41..493f1f12bf2dd260c56421c20f60b5a65a1d8741 100644 (file)
@@ -2309,11 +2309,14 @@ clock_select(void)
         * Allocate dynamic space depending on the number of
         * associations.
         */
-       endpoint_size = peer_count * 3 * sizeof(struct endpoint);
-       indx_size = peer_count * 3 * sizeof(int);
-       peers_size = peer_count * sizeof(struct peer *);
-       synch_size = peer_count * sizeof(double);
-       error_size = peer_count * sizeof(double);
+       nlist = 0;
+       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);
        octets = endpoint_size + indx_size + peers_size + synch_size +
            error_size;
        endpoint = erealloc(endpoint, octets);
@@ -2395,7 +2398,9 @@ clock_select(void)
                e = peer->offset;        /* upper end */
                f = root_distance(peer);
                e = e + f;
+               j = 0;
                for (i = nl3 - 1; i >= 0; i--) {
+                       j = nl3 - 1 + 2;
                        if (e >= endpoint[indx[i]].val)
                                break;