diff options
Diffstat (limited to 'contrib/ntp/ntpd/ntp_peer.c')
-rw-r--r-- | contrib/ntp/ntpd/ntp_peer.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/contrib/ntp/ntpd/ntp_peer.c b/contrib/ntp/ntpd/ntp_peer.c index 495ee30..d42d804 100644 --- a/contrib/ntp/ntpd/ntp_peer.c +++ b/contrib/ntp/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); +} |