From 90dd1b1c373ffae444881ff6d09d0a506e54bbde Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Fri, 29 Nov 2019 10:23:16 +0100 Subject: [PATCH] syslogd: Always domark() timer, regardless of -mfoo value The domark() timer handles a lot of the critical maintenance action in syslogd, it must always be guaranteed to run. Signed-off-by: Joachim Nilsson --- src/syslogd.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/syslogd.c b/src/syslogd.c index 0bb5ec1..bbb4db1 100644 --- a/src/syslogd.c +++ b/src/syslogd.c @@ -428,9 +428,7 @@ int main(int argc, char *argv[]) (void)signal(SIGUSR1, Debug ? debug_switch : SIG_IGN); (void)signal(SIGXFSZ, SIG_IGN); (void)signal(SIGHUP, sighup_handler); - - LastAlarm = MarkInterval; - alarm(LastAlarm); + alarm(TIMERINTVL); logit("Starting.\n"); init(); @@ -1270,7 +1268,7 @@ static void logmsg(struct buf_msg *buffer) seconds = alarm(0); MarkSeq += LastAlarm - seconds; LastAlarm = seconds; - if (LastAlarm > TIMERINTVL) + if (LastAlarm > TIMERINTVL || LastAlarm <= 0) LastAlarm = TIMERINTVL; alarm(LastAlarm); } @@ -1295,6 +1293,8 @@ static void logmsg(struct buf_msg *buffer) MarkSeq += LastAlarm - alarm(0); LastAlarm = MarkInterval - MarkSeq; + if (LastAlarm > TIMERINTVL || LastAlarm <= 0) + LastAlarm = TIMERINTVL; alarm(LastAlarm); } } @@ -1935,8 +1935,9 @@ void domark(int signo) { struct filed *f; + now = time(NULL); + if (MarkInterval > 0) { - now = time(0); MarkSeq += LastAlarm; if (MarkSeq >= MarkInterval) { flog(INTERNAL_MARK | LOG_INFO, "-- MARK --"); @@ -1956,7 +1957,7 @@ void domark(int signo) } LastAlarm = MarkInterval - MarkSeq; - if (DupesPending && LastAlarm > TIMERINTVL) + if (LastAlarm > TIMERINTVL || LastAlarm <= 0) LastAlarm = TIMERINTVL; (void)alarm(LastAlarm);