From: Juergen Perlinger Date: Sun, 6 Dec 2015 20:33:26 +0000 (+0100) Subject: [Bug 2814] msyslog deadlock when signaled. perlinger@ntp.org X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=47cea12dd8f562c6cd2cb5bbbb9d89b0efb3234d;p=thirdparty%2Fntp.git [Bug 2814] msyslog deadlock when signaled. perlinger@ntp.org - applied patch by shenpeng11@huawei.com with minor adjustments bk: 56649b96kijAcKTVg2Gwvt6ZgHtmEA --- diff --git a/ChangeLog b/ChangeLog index 187220daa..0c69148db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,8 @@ * CID 1341681: Nits in sntp/tests/keyFile.c. HStenn. * CID 1341682: Nit in libntp/authreadkeys.c. HStenn. * CID 1341684: Nit in tests/ntpd/t-ntp_signd.c. HStenn. +* [Bug 2814] msyslog deadlock when signaled. perlinger@ntp.org + - applied patch by shenpeng11@huawei.com with minor adjustments * [Bug 2829] Look at pipe_fds in ntpd.c (did so. perlinger@ntp.org) * [Bug 2887] stratum -1 config results as showing value 99 - fudge stratum only accepts values [0..16]. perlinger@ntp.org diff --git a/ntpd/ntpd.c b/ntpd/ntpd.c index 7630aee43..27b8a814b 100644 --- a/ntpd/ntpd.c +++ b/ntpd/ntpd.c @@ -209,6 +209,11 @@ extern int syscall (int, ...); #if !defined(SIM) && defined(SIGDIE1) +static volatile int signalled = 0; +static volatile int signo = 0; + +/* In an ideal world, 'finish_safe()' would declared as noreturn... */ +static void finish_safe (int); static RETSIGTYPE finish (int); #endif @@ -1204,6 +1209,10 @@ int scmp_sc[] = { # ifdef HAVE_IO_COMPLETION_PORT for (;;) { +#if !defined(SIM) && defined(SIGDIE1) + if (signalled) + finish_safe(signo); +#endif GetReceivedBuffers(); # else /* normal I/O */ @@ -1211,6 +1220,10 @@ int scmp_sc[] = { 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; @@ -1330,9 +1343,9 @@ int scmp_sc[] = { /* * finish - exit gracefully */ -static RETSIGTYPE -finish( - int sig +static void +finish_safe( + int sig ) { const char *sig_desc; @@ -1353,6 +1366,16 @@ finish( peer_cleanup(); exit(0); } + +static RETSIGTYPE +finish( + int sig + ) +{ + signalled = 1; + signo = sig; +} + #endif /* !SIM && SIGDIE1 */