[Git][NTPsec/ntpsec][master] TESTFRAME: Refactor so intercept_log does not have to be visible.

Eric S. Raymond gitlab at mg.gitlab.com
Sun Nov 29 20:31:12 UTC 2015


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
69591694 by Eric S. Raymond at 2015-11-29T15:28:59Z
TESTFRAME: Refactor so intercept_log does not have to be visible.

Also, move the header file for the intercept layer; nothing in
libntp needs to see it.  Goes with "TESTFRAME progress - intercept calls to
read the leapsecond file."

- - - - -


4 changed files:

- ntpd/ntp_config.c
- ntpd/ntp_intercept.c
- include/ntp_intercept.h → ntpd/ntp_intercept.h
- ntpd/ntpd.c


Changes:

=====================================
ntpd/ntp_config.c
=====================================
--- a/ntpd/ntp_config.c
+++ b/ntpd/ntp_config.c
@@ -35,6 +35,7 @@
 #include "lib_strbuf.h"
 #include "ntp_assert.h"
 #include "ntp_random.h"
+#include "ntp_intercept.h"
 /*
  * [Bug 467]: Some linux headers collide with CONFIG_PHONE and CONFIG_KEYS
  * so #include these later.


=====================================
ntpd/ntp_intercept.c
=====================================
--- a/ntpd/ntp_intercept.c
+++ b/ntpd/ntp_intercept.c
@@ -354,4 +354,33 @@ intercept_getauthkeys(
     /* FIXME: replay logic goes here */
 }
 
+#if !defined(SIM) && defined(SIGDIE1)
+/*
+ * finish - exit gracefully
+ */
+void intercept_finish(const int sig)
+{
+    if (mode == capture)
+	printf("finish %d\n", 0);
+
+    if (mode != replay) {
+	const char *sig_desc;
+
+	sig_desc = NULL;
+	sig_desc = strsignal(sig);
+	if (sig_desc == NULL)
+		sig_desc = "";
+	msyslog(LOG_NOTICE, "%s exiting on signal %d (%s)", progname,
+		sig, sig_desc);
+	/* See Bug 2513 and Bug 2522 re the unlink of PIDFILE */
+# if defined(HAVE_DNS_SD_H) && defined(ENABLE_MDNS_REGISTRATION)
+	if (mdns != NULL)
+		DNSServiceRefDeallocate(mdns);
+# endif
+	peer_cleanup();
+	exit(0);
+    }
+}
+#endif	/* !SIM && SIGDIE1 */
+
 /* end */


=====================================
include/ntp_intercept.h → ntpd/ntp_intercept.h
=====================================
--- a/include/ntp_intercept.h
+++ b/ntpd/ntp_intercept.h
@@ -41,4 +41,10 @@ extern bool intercept_leapsec_load_file(const char * fname, struct stat * sb,
 					bool force, bool logall);
 void intercept_getauthkeys(const char *);
 
+#if !defined(SIM) && defined(SIGDIE1)
+void intercept_finish(const int);
+#endif
+
+
+
 /* end */


=====================================
ntpd/ntpd.c
=====================================
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -117,10 +117,6 @@ extern bool	check_netinfo;
 
 bool was_alarmed;
 
-#if !defined(SIM) && defined(SIGDIE1)
-static	void	finish		(int);
-#endif
-
 #if !defined(SIM) && defined(HAVE_WORKING_FORK)
 static int	wait_child_sync_if	(int, long);
 #endif
@@ -724,13 +720,13 @@ ntpdmain(
 	 * Set up signals we pay attention to locally.
 	 */
 # ifdef SIGDIE1
-	signal_no_reset(SIGDIE1, finish);
-	signal_no_reset(SIGDIE2, finish);
-	signal_no_reset(SIGDIE3, finish);
-	signal_no_reset(SIGDIE4, finish);
+	signal_no_reset(SIGDIE1, intercept_finish);
+	signal_no_reset(SIGDIE2, intercept_finish);
+	signal_no_reset(SIGDIE3, intercept_finish);
+	signal_no_reset(SIGDIE4, intercept_finish);
 # endif
 # ifdef SIGBUS
-	signal_no_reset(SIGBUS, finish);
+	signal_no_reset(SIGBUS, intercept_finish);
 # endif
 
 # ifdef DEBUG
@@ -1051,36 +1047,6 @@ ntpdmain(
 }
 #endif	/* !SIM */
 
-
-#if !defined(SIM) && defined(SIGDIE1)
-/*
- * finish - exit gracefully
- */
-static void
-finish(
-	int sig
-	)
-{
-	const char *sig_desc;
-
-	intercept_log("event shutdown 0\n");
-	sig_desc = NULL;
-	sig_desc = strsignal(sig);
-	if (sig_desc == NULL)
-		sig_desc = "";
-	msyslog(LOG_NOTICE, "%s exiting on signal %d (%s)", progname,
-		sig, sig_desc);
-	/* See Bug 2513 and Bug 2522 re the unlink of PIDFILE */
-# if defined(HAVE_DNS_SD_H) && defined(ENABLE_MDNS_REGISTRATION)
-	if (mdns != NULL)
-		DNSServiceRefDeallocate(mdns);
-# endif
-	peer_cleanup();
-	exit(0);
-}
-#endif	/* !SIM && SIGDIE1 */
-
-
 #ifndef SIM
 /*
  * wait_child_sync_if - implements parent side of -w/--wait-sync



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/695916945b919b1e1faeafc69097be53fb2ab0d7
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20151129/817f5f01/attachment.html>


More information about the vc mailing list