]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2346] "graceful termination" signals do not do peer cleanup
authorHarlan Stenn <stenn@ntp.org>
Sun, 29 Mar 2015 01:49:10 +0000 (01:49 +0000)
committerHarlan Stenn <stenn@ntp.org>
Sun, 29 Mar 2015 01:49:10 +0000 (01:49 +0000)
bk: 55175a16W3_Wss1Z2sowk4vnvGC8ng

ChangeLog
include/ntpd.h
ntpd/ntp_peer.c
ntpd/ntpd.c

index aea1108a637e55d7eaf99783db4ef98509908081..bbc77380cc445b8c50fd9a36aca7a237e000157c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 
 * [Bug 1787] DCF77's formerly "antenna" bit is "call bit" since 2003.
 * [Bug 1960] setsockopt IPV6_MULTICAST_IF: Invalid argument.
+* [Bug 2346] "graceful termination" signals do not do peer cleanup.
 * [Bug 2728] See if C99-style structure initialization works.
 * [Bug 2747] Upgrade libevent to 2.1.5-beta.
 * [Bug 2749] ntp/lib/NTP/Util.pm needs update for ntpq -w, IPv6, .POOL. .
index 9f07e4ef726105580b55439ebb52478a35191e97..8ccd5d2e0fe545eced1ace8faf6077387c649f02 100644 (file)
@@ -188,6 +188,7 @@ extern      void    unpeer          (struct peer *);
 extern void    clear_all       (void);
 extern int     score_all       (struct peer *);
 extern struct peer *findmanycastpeer(struct recvbuf *);
+extern void    peer_cleanup    (void);
 
 /* ntp_crypto.c */
 #ifdef AUTOKEY
index 495ee30af1a173543f23ab4371f75282cd96f342..d42d804d444d4515300dd948069725f97c8788ea 100644 (file)
@@ -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);
+}
index c017ef34d7db376f8147d6ca05395343d24c6b82..529e6ce1b0cc52e4dfe675cc4a70099e24eeb6dc 100644 (file)
@@ -1262,6 +1262,7 @@ finish(
        if (mdns != NULL)
                DNSServiceRefDeallocate(mdns);
 # endif
+       peer_cleanup();
        exit(0);
 }
 #endif /* !SIM && SIGDIE1 */