]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
preempt stuff from Dave Mills
authorHarlan Stenn <stenn@ntp.org>
Fri, 12 Aug 2005 08:45:21 +0000 (04:45 -0400)
committerHarlan Stenn <stenn@ntp.org>
Fri, 12 Aug 2005 08:45:21 +0000 (04:45 -0400)
bk: 42fc61a1M8r1T2lgaxXUBU2nXz048A

include/ntpd.h
ntpd/ntp_peer.c
ntpd/ntp_proto.c

index af29f62a6f1d156fddd0fce9ca6f4d1f9942e1bc..501238dd3b2b33d423fa85c92cfe4685ed9539c1 100644 (file)
@@ -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
index 38a2a00412a5db705b3ef1030ea32395ad6043b9..629c4bf6222b945237c5eb80ac2df23d43192bac 100644 (file)
@@ -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);
-                       }
                }
        }
 }
index f221610d56dad86c278408cf691bf8dff41c6dd5..eaa286a4380f891d532e1f679c8daf344e52ad91 100644 (file)
@@ -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;
                }
        }