From: Harlan Stenn Date: Fri, 12 Aug 2005 08:45:21 +0000 (-0400) Subject: preempt stuff from Dave Mills X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf5460b9a82d779b3f98f2d666d5dcc25c19c516;p=thirdparty%2Fntp.git preempt stuff from Dave Mills bk: 42fc61a1M8r1T2lgaxXUBU2nXz048A --- diff --git a/include/ntpd.h b/include/ntpd.h index af29f62a6f..501238dd3b 100644 --- a/include/ntpd.h +++ b/include/ntpd.h @@ -345,8 +345,8 @@ extern u_long assocpeer_calls; /* number of calls to findpeerbyassoc */ extern u_long peer_allocations; /* number of allocations from the free list */ extern u_long peer_demobilizations; /* number of structs freed to free list */ extern int total_peer_structs; /* number of peer structs in circulation */ -extern int peer_associations; /* number of active associations */ - +extern int peer_associations; /* mobilized associations */ +extern int peer_preempt; /* preemptable associations */ /* ntp_proto.c */ /* * System variables are declared here. See Section 3.2 of the diff --git a/ntpd/ntp_peer.c b/ntpd/ntp_peer.c index 38a2a00412..629c4bf622 100644 --- a/ntpd/ntp_peer.c +++ b/ntpd/ntp_peer.c @@ -98,7 +98,8 @@ u_long assocpeer_calls; /* calls to findpeerbyassoc */ u_long peer_allocations; /* allocations from free list */ u_long peer_demobilizations; /* structs freed to free list */ int total_peer_structs; /* peer structs */ -int peer_associations; /* active associations */ +int peer_associations; /* mobilized associations */ +int peer_preempt; /* preemptable associations */ static struct peer init_peer_alloc[INIT_PEER_ALLOC]; /* init alloc */ static void getmorepeermem P((void)); @@ -338,12 +339,15 @@ unpeer( #endif /* OPENSSL */ #ifdef DEBUG if (debug) - printf("demobilize %u %d\n", peer_to_remove->associd, - peer_associations); + printf("demobilize %u %d %d\n", peer_to_remove->associd, + peer_associations, peer_preempt); #endif hash = NTP_HASH_ADDR(&peer_to_remove->srcadr); peer_hash_count[hash]--; peer_demobilizations++; + peer_associations--; + if (peer_to_remove->flags & FLAG_PREEMPT) + peer_preempt--; #ifdef REFCLOCK /* * If this peer is actually a clock, shut it down first @@ -396,7 +400,6 @@ unpeer( peer_to_remove->next = peer_free; peer_free = peer_to_remove; peer_free_count++; - peer_associations--; } @@ -543,6 +546,8 @@ newpeer( peer_free = peer->next; peer_free_count--; peer_associations++; + if (flags & FLAG_PREEMPT) + peer_preempt++; memset((char *)peer, 0, sizeof(struct peer)); /* @@ -894,9 +899,8 @@ resetmanycast(void) for (peer = peer_hash[i]; peer != NULL; peer = next_peer) { next_peer= peer->next; - if (peer->cast_flags & MDF_ACLNT) { + if (peer->cast_flags & MDF_ACLNT) unpeer(peer); - } } } } diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c index f221610d56..eaa286a438 100644 --- a/ntpd/ntp_proto.c +++ b/ntpd/ntp_proto.c @@ -141,22 +141,26 @@ transmit( } /* - * In manycast mode we start with the minpoll interval and unity - * ttl. The ttl is increased by one for each poll until either - * enough servers have been found or the maximum ttl is reached. - * About once per day when the agreement parameters are - * refreshed, the manycast clients are reset and we start from - * the beginning. This is to catch and clamp the ttl to the - * lowest practical value and avoid knocking on spurious doors. + * In manycast mode we start with unity ttl. The ttl is + * increased by one for each poll until either sys_maxclock + * servers have been found or the maximum ttl is reached. When + * sys_maxclock servers are found we stop polling until either + * fewer servers are available */ if (peer->cast_flags & MDF_ACAST) { - if (sys_survivors >= sys_maxclock) - return; - peer->outdate = current_time; - if (peer->ttl < sys_ttlmax) - peer->ttl++; - peer_xmit(peer); + if (sys_survivors < sys_minclock || peer_preempt < + sys_maxclock) { +#if DEBUG + if (debug) + printf("transmit: survivors %d minclock %d preempt %d maxclock %d\n", + sys_survivors, sys_minclock, peer_preempt, + sys_maxclock); +#endif + if (peer->ttl < sys_ttlmax) + peer->ttl++; + peer_xmit(peer); + } poll_update(peer, hpoll); return; } @@ -177,7 +181,7 @@ transmit( oreach = peer->reach; if (peer->unreach > NTP_UNREACH) { if (peer->flags & FLAG_PREEMPT && - peer_associations > sys_maxclock) { + peer_preempt > sys_maxclock) { unpeer(peer); return; @@ -2011,9 +2015,6 @@ clock_select(void) "no servers reachable"); report_event(EVNT_PEERSTCHG, NULL); } - if (osurv > 0) - resetmanycast(); - return; } }