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
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));
#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
peer_to_remove->next = peer_free;
peer_free = peer_to_remove;
peer_free_count++;
- peer_associations--;
}
peer_free = peer->next;
peer_free_count--;
peer_associations++;
+ if (flags & FLAG_PREEMPT)
+ peer_preempt++;
memset((char *)peer, 0, sizeof(struct peer));
/*
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);
- }
}
}
}
}
/*
- * 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;
}
oreach = peer->reach;
if (peer->unreach > NTP_UNREACH) {
if (peer->flags & FLAG_PREEMPT &&
- peer_associations > sys_maxclock) {
+ peer_preempt > sys_maxclock) {
unpeer(peer);
return;
"no servers reachable");
report_event(EVNT_PEERSTCHG, NULL);
}
- if (osurv > 0)
- resetmanycast();
- return;
}
}