From e0c2d3ad0df4638f4cba53bf9efb1586b20300a1 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Mon, 9 Dec 2019 13:52:51 +0100 Subject: [PATCH] syslogd: Only log INTERNAL_MARK every MarkInterval Internal log messages of INTERNAL_MARK time were created every 30 seconds (TIMERINTVL) instead of every MarkInterval (default 20 min). Signed-off-by: Joachim Nilsson --- src/syslogd.c | 20 ++++++++++++++++---- src/syslogd.h | 3 +-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/syslogd.c b/src/syslogd.c index 46f34b4..339bad8 100644 --- a/src/syslogd.c +++ b/src/syslogd.c @@ -401,9 +401,14 @@ int main(int argc, char *argv[]) /* * Set up timer callbacks for -- MARK -- et al */ - if (MarkInterval > 0) - timer_add(TIMERINTVL, domark, NULL); - timer_add(FLUSHINTVL, doflush, NULL); + if (MarkInterval > 0) { + int interval = MarkInterval / 2; + + if (interval < 30) + interval = 30; + timer_add(interval, domark, NULL); + } + timer_add(TIMERINTVL, doflush, NULL); /* Start 'em */ timer_start(); @@ -1896,7 +1901,14 @@ static void forw_lookup(struct filed *f) void domark(void *arg) { - flog(INTERNAL_MARK | LOG_INFO, "-- MARK --"); + static time_t t_last = 0; + time_t t_now; + + t_now = timer_now(); + if (t_now >= t_last + MarkInterval) { + flog(INTERNAL_MARK | LOG_INFO, "-- MARK --"); + t_last = t_now; + } } void doflush(void *arg) diff --git a/src/syslogd.h b/src/syslogd.h index ba9e526..b622a6c 100644 --- a/src/syslogd.h +++ b/src/syslogd.h @@ -51,8 +51,7 @@ #define MAXSVLINE MAXLINE /* maximum saved line length */ #define DEFUPRI (LOG_USER | LOG_NOTICE) #define DEFSPRI (LOG_KERN | LOG_CRIT) -#define TIMERINTVL 30 /* interval for checking flush, mark */ -#define FLUSHINTVL 10 /* interval for checking flush, mark */ +#define TIMERINTVL 30 /* interval for checking flush/nslookip */ #define RCVBUF_MINSIZE (80 * MAXLINE) /* minimum size of dgram rcv buffer */ /*