From 2658319224574a54a1c76ee02b6a7f3af5dab068 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 9 Jun 2008 16:38:53 +0200 Subject: made rsyslog tickless in the (usual and default) case that repeated message reduction is turned off. More info: http://blog.gerhards.net/2008/06/coding-to-save-environment.html --- tools/syslogd.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'tools/syslogd.c') diff --git a/tools/syslogd.c b/tools/syslogd.c index 8b829771..7f415f3c 100644 --- a/tools/syslogd.c +++ b/tools/syslogd.c @@ -2491,15 +2491,22 @@ mainloop(void) struct timeval tvSelectTimeout; BEGINfunc - while(!bFinished){ - /* first check if we have any internal messages queued and spit them out */ - /* TODO: do we need this any longer? I doubt it, but let's care about it - * later -- rgerhards, 2007-12-21 - */ - processImInternal(); + /* first check if we have any internal messages queued and spit them out. We used + * to do that on any loop iteration, but that is no longer necessry. The reason + * is that once we reach this point here, we always run on multiple threads and + * thus the main queue is properly initialized. -- rgerhards, 2008-06-09 + */ + processImInternal(); - /* this is now just a wait */ - tvSelectTimeout.tv_sec = TIMERINTVL; + while(!bFinished){ + /* this is now just a wait - please note that we do use a near-"eternal" + * timeout of 1 day if we do not have repeated message reduction turned on + * (which it is not by default). This enables us to help safe the environment + * by not unnecessarily awaking rsyslog on a regular tick (just think + * powertop, for example). In that case, we primarily wait for a signal, + * but a once-a-day wakeup should be quite acceptable. -- rgerhards, 2008-06-09 + */ + tvSelectTimeout.tv_sec = (bReduceRepeatMsgs == 1) ? TIMERINTVL : 86400 /*1 day*/; tvSelectTimeout.tv_usec = 0; select(1, NULL, NULL, NULL, &tvSelectTimeout); if(bFinished) @@ -2526,7 +2533,8 @@ mainloop(void) * for the time being, I think the remaining risk can be accepted. * rgerhards, 2008-01-10 */ - doFlushRptdMsgs(); + if(bReducedRepeatMsgs == 1) + doFlushRptdMsgs(); if(restart) { dbgprintf("\nReceived SIGHUP, reloading rsyslogd.\n"); -- cgit v1.2.3