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 <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2019-11-29 10:23:16 +01:00
parent 280b5fd3ec
commit 90dd1b1c37

View File

@ -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);