diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-06-09 16:38:53 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-06-09 16:38:53 +0200 |
commit | 2658319224574a54a1c76ee02b6a7f3af5dab068 (patch) | |
tree | 6b26b7e9fb3e25b0e10a9d69da0b8d70987563af /tools/syslogd.c | |
parent | 55e01da2ec3de1b5c6b15e4154235f0eedbb68da (diff) | |
download | rsyslog-2658319224574a54a1c76ee02b6a7f3af5dab068.tar.gz rsyslog-2658319224574a54a1c76ee02b6a7f3af5dab068.tar.xz rsyslog-2658319224574a54a1c76ee02b6a7f3af5dab068.zip |
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
Diffstat (limited to 'tools/syslogd.c')
-rw-r--r-- | tools/syslogd.c | 26 |
1 files changed, 17 insertions, 9 deletions
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"); |