From 9e72f53d724f7cc66a8f205312c5a4e40653bfb5 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 31 Dec 2015 12:13:47 +0100 Subject: syslogd: only use asynchronous signal delivery for marks marks are currently delivered in a way that can cause a deadlock if they happen while the semaphone is held, and nothing prevents this from happening. Change the code to only perform asynchronous logging. --- sysklogd/syslogd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index 1ee712c..1a1c8f9 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c @@ -72,6 +72,7 @@ static int logFileRotate = 1; /* interval between marks in seconds */ static int MarkInterval = 20 * 60; +static int pending_mark = 0; /* localhost's name */ static char LocalHostName[64]; @@ -546,7 +547,7 @@ static void quit_signal(int sig) static void domark(int sig) { if (MarkInterval > 0) { - logMessage(LOG_SYSLOG | LOG_INFO, "-- MARK --"); + pending_mark++; alarm(MarkInterval); } } @@ -716,6 +717,11 @@ static void doSyslogd(void) bb_perror_msg_and_die("select error"); } + if (pending_mark > 0) { + pending_mark = 0; + logMessage(LOG_SYSLOG | LOG_INFO, "-- MARK --"); + } + /* alarm, timeout, etc */ if (ret <= 0) continue; -- 1.7.12.1