[Git][NTPsec/ntpsec][master] For TESTFRAME, log termination properly even in ntpdate mode.

Eric S. Raymond gitlab at mg.gitlab.com
Thu Dec 10 22:39:31 UTC 2015


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


Commits:
d576118e by Eric S. Raymond at 2015-12-10T17:38:12Z
For TESTFRAME, log termination properly even in ntpdate mode.

- - - - -


6 changed files:

- include/ntpd.h
- ntpd/ntp_intercept.c
- ntpd/ntp_intercept.h
- ntpd/ntp_loopfilter.c
- ntpd/ntp_proto.c
- ntpd/ntpd.c


Changes:

=====================================
include/ntpd.h
=====================================
--- a/include/ntpd.h
+++ b/include/ntpd.h
@@ -540,6 +540,7 @@ extern const char *chrootdir;	/* directory to chroot() to */
 #ifdef HAVE_WORKING_FORK
 extern	int	waitsync_fd_to_close;	/* -w/--wait-sync */
 #endif
+extern  void	finish		(int sig);
 
 /* ntservice.c */
 #ifdef SYS_WINNT


=====================================
ntpd/ntp_intercept.c
=====================================
--- a/ntpd/ntp_intercept.c
+++ b/ntpd/ntp_intercept.c
@@ -139,7 +139,9 @@ void intercept_argparse(int *argc, char ***argv)
 
     if (mode == capture)
     {
-	printf("event startup");
+	printf("NTP replay version 1\n");
+
+	printf("startup");
 	for (i = 1; i < *argc; i++)
 	    if (strcmp((*argv)[i], "-y") != 0 && strcmp((*argv)[i], "-Y") != 0)
 		printf(" %s", (*argv)[i]);
@@ -210,7 +212,7 @@ void intercept_get_systime(const char *legend, l_fp *now)
     }
 
     if (mode != none)
-	printf("event systime %s %s\n", legend, lfpdump(now));
+	printf("systime %s %s\n", legend, lfpdump(now));
 
 }
 
@@ -221,7 +223,7 @@ long intercept_ntp_random(const char *legend)
     /* FIXME: replay logic goes here */
 
     if (mode != none)
-	printf("event random %s %ld\n", legend, rand);
+	printf("random %s %ld\n", legend, rand);
 
     return rand;
 }
@@ -229,7 +231,7 @@ long intercept_ntp_random(const char *legend)
 void intercept_timer(void)
 {
     if (mode != none)
-	printf("event timer\n");
+	printf("timer\n");
     timer();
 }
 
@@ -252,7 +254,7 @@ bool intercept_drift_read(const char *drift_file, double *drift)
     }
 
     if (mode != none)
-	printf("event drift-read %.3f\n", *drift);
+	printf("drift-read %.3f\n", *drift);
 
     return true;
 }
@@ -260,7 +262,7 @@ bool intercept_drift_read(const char *drift_file, double *drift)
 void intercept_drift_write(char *driftfile, double drift)
 {
     if (mode != none)
-	printf("event drift-write %.3f\n", drift);
+	printf("drift-write %.3f\n", drift);
 
     if (mode != replay)
     {
@@ -296,7 +298,7 @@ void intercept_drift_write(char *driftfile, double drift)
 int intercept_adjtime(const struct timeval *ntv, struct timeval *otv)
 /* old-fashioned BSD call for systems with no PLL */
 {
-    printf("event adjtime %ld %ld %ld %ld",
+    printf("adjtime %ld %ld %ld %ld",
 	   (long)ntv->tv_sec, (long)ntv->tv_usec, (long)ntv->tv_sec, (long)ntv->tv_usec);
 
     if (mode != replay)
@@ -317,7 +319,7 @@ int intercept_ntp_adjtime(struct timex *tx)
 	res = ntp_adjtime(tx);
 
     if (mode != none)
-	printf("event ntp_adjtime %u %ld %ld %ld %ld %i %ld %ld %ld %ld %ld %i %ld %ld %ld %ld %d\n",
+	printf("ntp_adjtime %u %ld %ld %ld %ld %i %ld %ld %ld %ld %ld %i %ld %ld %ld %ld %d\n",
 	       tx->modes,
 	       tx->offset,
 	       tx->freq,
@@ -344,7 +346,7 @@ int intercept_ntp_adjtime(struct timex *tx)
 int intercept_set_tod(struct timespec *tvs)
 {
     if (mode != none)
-	printf("event set_tod %ld %ld\n", (long)tvs->tv_sec, tvs->tv_nsec);
+	printf("set_tod %ld %ld\n", (long)tvs->tv_sec, tvs->tv_nsec);
 
     if (mode == replay)
 	return ntp_set_tod(tvs);
@@ -397,7 +399,7 @@ void intercept_sendpkt(const char *legend,
 	sendpkt(dest, ep, ttl, pkt, len);
 
     if (mode != none) {
-	printf("event sendpkt \"%s\" ", legend);
+	printf("sendpkt \"%s\" ", legend);
 	packet_dump(dest, pkt, len);
 	fputs("\n", stdout);
     }
@@ -415,7 +417,7 @@ void intercept_receive(struct recvbuf *rbufp)
 	 * the protocol machine.  We don't dump srcadr because only
 	 * the parse clock uses that.
 	 */
-	printf("event receive %0x %s %s ",
+	printf("receive %0x %s %s ",
 	       rbufp->cast_flags,
 	       lfpdump(&rbufp->recv_time),
 	       rbufp->dstadr->name);
@@ -452,15 +454,12 @@ intercept_getauthkeys(
     /* FIXME: replay logic goes here */
 }
 
-void intercept_finish(int sig)
+void intercept_exit(int sig)
 {
     if (mode != none)
 	printf("finish %d\n", sig);
 
-#if !defined(SIM) && defined(SIGDIE1)
-    extern void finish(int);	/* ugh */
-    finish(sig);
-#endif	/* !SIM && SIGDIE1 */
+    exit(sig);
 }
 
 /* end */


=====================================
ntpd/ntp_intercept.h
=====================================
--- a/ntpd/ntp_intercept.h
+++ b/ntpd/ntp_intercept.h
@@ -43,11 +43,6 @@ int intercept_set_tod(struct timespec *tvs);
 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
-
-
+void intercept_exit(const int);
 
 /* end */


=====================================
ntpd/ntp_loopfilter.c
=====================================
--- a/ntpd/ntp_loopfilter.c
+++ b/ntpd/ntp_loopfilter.c
@@ -510,7 +510,7 @@ local_clock(
 		}
 		record_loop_stats(fp_offset, drift_comp, clock_jitter,
 		    clock_stability, sys_poll);
-		exit (0);
+		intercept_exit(0);
 	}
 
 	/*


=====================================
ntpd/ntp_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -358,7 +358,7 @@ transmit(
 					if (!termlogit)
 						printf(
 						    "ntpd: no servers found\n");
-					exit (0);
+					intercept_exit(0);
 				}
 			}
 		}


=====================================
ntpd/ntpd.c
=====================================
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -722,13 +722,13 @@ ntpdmain(
 	 * Set up signals we pay attention to locally.
 	 */
 # ifdef SIGDIE1
-	signal_no_reset(SIGDIE1, intercept_finish);
-	signal_no_reset(SIGDIE2, intercept_finish);
-	signal_no_reset(SIGDIE3, intercept_finish);
-	signal_no_reset(SIGDIE4, intercept_finish);
+	signal_no_reset(SIGDIE1, finish);
+	signal_no_reset(SIGDIE2, finish);
+	signal_no_reset(SIGDIE3, finish);
+	signal_no_reset(SIGDIE4, finish);
 # endif
 # ifdef SIGBUS
-	signal_no_reset(SIGBUS, intercept_finish);
+	signal_no_reset(SIGBUS, finish);
 # endif
 
 # ifdef DEBUG
@@ -1071,8 +1071,6 @@ finish(
 {
 	const char *sig_desc;
 
-	intercept_log("event shutdown 0\n");
-	sig_desc = NULL;
 	sig_desc = strsignal(sig);
 	if (sig_desc == NULL)
 		sig_desc = "";
@@ -1084,7 +1082,7 @@ finish(
 		DNSServiceRefDeallocate(mdns);
 # endif
 	peer_cleanup();
-	exit(0);
+	intercept_exit(0);
 }
 #endif	/* !SIM && SIGDIE1 */
 



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/d576118ea4f621ce3226abc09ae4f5f6ae38c4ae
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20151210/37916355/attachment.html>


More information about the vc mailing list