summaryrefslogtreecommitdiff
path: root/ntpd/ntp_peer.c
diff options
context:
space:
mode:
Diffstat (limited to 'ntpd/ntp_peer.c')
-rw-r--r--ntpd/ntp_peer.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/ntpd/ntp_peer.c b/ntpd/ntp_peer.c
index 495ee30..d42d804 100644
--- a/ntpd/ntp_peer.c
+++ b/ntpd/ntp_peer.c
@@ -92,6 +92,7 @@ int peer_free_count; /* count of free structures */
* value every time an association is mobilized.
*/
static associd_t current_association_ID; /* association ID */
+static associd_t initial_association_ID; /* association ID */
/*
* Memory allocation watermarks.
@@ -147,6 +148,7 @@ init_peer(void)
do
current_association_ID = ntp_random() & ASSOCID_MAX;
while (!current_association_ID);
+ initial_association_ID = current_association_ID;
}
@@ -1036,3 +1038,21 @@ findmanycastpeer(
return peer;
}
+
+/* peer_cleanup - clean peer list prior to shutdown */
+void peer_cleanup(void)
+{
+ struct peer *peer;
+ associd_t assoc;
+
+ for (assoc = initial_association_ID; assoc != current_association_ID; assoc++) {
+ if (assoc != 0U) {
+ peer = findpeerbyassoc(assoc);
+ if (peer != NULL)
+ unpeer(peer);
+ }
+ }
+ peer = findpeerbyassoc(current_association_ID);
+ if (peer != NULL)
+ unpeer(peer);
+}