[Git][NTPsec/ntpsec][master] Forward-port from Classic: [Bug 2814] msyslog deadlock when signaled.

Eric S. Raymond gitlab at mg.gitlab.com
Mon Mar 21 15:23:47 UTC 2016


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


Commits:
ba3559e1 by Eric S. Raymond at 2016-03-21T11:22:07-04:00
Forward-port from Classic: [Bug 2814] msyslog deadlock when signaled.

- - - - -


2 changed files:

- NEWS
- ntpd/ntpd.c


Changes:

=====================================
NEWS
=====================================
--- a/NEWS
+++ b/NEWS
@@ -8,14 +8,16 @@ on user-visible changes.
 
 == Repository head ==
 
-The following reflect forward-ported fixes from Classic:
+The following fixes have been forward-ported from Classic:
 
 [Bug 2772] adj_systime overflows tv_usec
+[Bug 2814] msyslog deadlock when signaled.
 [Bug 2829] Look at pipe_fds in ntpd.c
 [Bug 2887] fudge stratum only accepts values [0..16].
 [Bug 2937] (NTPQ) nextvar() missing length check
-[Bug 2958] ntpq: fatal error messages need a final newline. Craig Leres.
+[Bug 2958] ntpq: fatal error messages need a final newline.
 [Bug 2965] Local clock didn't work since 4.2.8p4.
+[Bug 2969] Segfault from ntpq/mrulist when looking at server with lots of clients
 
 == 2016-03-15: 0.9.2 ==
 


=====================================
ntpd/ntpd.c
=====================================
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -45,6 +45,13 @@ extern bool sandbox(const bool droproot,
 		    const char *chrootdir,
 		    bool want_dynamic_interface_tracking);
 
+#if !defined(SIM) && defined(SIGDIE1)
+static volatile bool signalled	= false;
+static volatile int signo	= 0;
+/* In an ideal world, 'finish_safe()' would declared as noreturn... */
+static	void		finish_safe	(int);
+#endif
+
 #ifdef SIGDANGER
 # include <ulimit.h>
 #endif /* SIGDANGER */
@@ -957,6 +964,10 @@ static void mainloop(void)
 
 # ifdef HAVE_IO_COMPLETION_PORT
 	for (;;) {
+#if !defined(SIM) && defined(SIGDIE1)
+		if (signalled)
+			finish_safe(signo);
+#endif
 		GetReceivedBuffers();
 # else /* normal I/O */
 
@@ -964,6 +975,10 @@ static void mainloop(void)
 	was_alarmed = false;
 
 	for (;;) {
+#if !defined(SIM) && defined(SIGDIE1)
+		if (signalled)
+			finish_safe(signo);
+#endif
 		if (alarm_flag) {	/* alarmed? */
 			was_alarmed = true;
 			alarm_flag = false;
@@ -1082,8 +1097,8 @@ static void mainloop(void)
 /*
  * finish - exit gracefully
  */
-void
-finish(
+static void
+finish_safe(
 	int sig
 	)
 {
@@ -1102,6 +1117,16 @@ finish(
 	peer_cleanup();
 	intercept_exit(0);
 }
+
+void
+finish(
+	int	sig
+	)
+{
+	signalled = true;
+	signo = sig;
+}
+
 #endif	/* !SIM && SIGDIE1 */
 
 



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


More information about the vc mailing list