summaryrefslogtreecommitdiffstats
path: root/tools/syslogd.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-10-19 11:01:37 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2012-10-19 11:01:37 +0200
commit9516e8f99f0385eb7948df9b6af87b51d3462ccb (patch)
treeed48a1322b72d59e0a827bb409d99a23982a2a11 /tools/syslogd.c
parentfb53a0420f84400628fea810306a9936933ec875 (diff)
downloadrsyslog-9516e8f99f0385eb7948df9b6af87b51d3462ccb.tar.gz
rsyslog-9516e8f99f0385eb7948df9b6af87b51d3462ccb.tar.bz2
rsyslog-9516e8f99f0385eb7948df9b6af87b51d3462ccb.zip
ratelimit: add default ratelimiter
Diffstat (limited to 'tools/syslogd.c')
-rw-r--r--tools/syslogd.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/tools/syslogd.c b/tools/syslogd.c
index a8c5d887..cb6a47cd 100644
--- a/tools/syslogd.c
+++ b/tools/syslogd.c
@@ -221,6 +221,7 @@ struct queuefilenames_s {
} *queuefilenames = NULL;
+static ratelimit_t *dflt_ratelimiter = NULL; /* ratelimiter for submits without explicit one */
int MarkInterval = 20 * 60; /* interval between marks in seconds - read-only after startup */
int send_to_all = 0; /* send message to all IPv4/IPv6 addresses */
static int NoFork = 0; /* don't fork - don't run in daemon mode - read-only after startup */
@@ -432,6 +433,12 @@ submitErrMsg(int iErr, uchar *msg)
}
+static inline rsRetVal
+submitMsgWithDfltRatelimiter(msg_t *pMsg)
+{
+ return ratelimitAddMsg(dflt_ratelimiter, NULL, pMsg);
+}
+
/* rgerhards 2004-11-09: the following is a function that can be used
* to log a message orginating from the syslogd itself.
*/
@@ -483,7 +490,7 @@ logmsgInternal(int iErr, int pri, uchar *msg, int flags)
/* we have the queue, so we can simply provide the
* message to the queue engine.
*/
- submitMsg2(pMsg);
+ submitMsgWithDfltRatelimiter(pMsg);
}
finalize_it:
RETiRet;
@@ -594,7 +601,7 @@ submitMsg2(msg_t *pMsg)
/* if a plugin logs a message during shutdown, the queue may no longer exist */
if(pQueue == NULL) {
- DBGPRINTF("submitMsg() could not submit message - "
+ DBGPRINTF("submitMsg2() could not submit message - "
"queue does (no longer?) exist - ignored\n");
FINALIZE;
}
@@ -609,7 +616,7 @@ finalize_it:
rsRetVal
submitMsg(msg_t *pMsg)
{
- return submitMsg2(pMsg);
+ return submitMsgWithDfltRatelimiter(pMsg);
}
@@ -1246,7 +1253,7 @@ static inline void processImInternal(void)
msg_t *pMsg;
while(iminternalRemoveMsg(&pMsg) == RS_RET_OK) {
- submitMsg(pMsg);
+ submitMsgWithDfltRatelimiter(pMsg);
}
}
@@ -2023,6 +2030,9 @@ int realMain(int argc, char **argv)
}
CHKiRet(localRet);
+ CHKiRet(ratelimitNew(&dflt_ratelimiter, "rsyslogd", NULL));
+ /* TODO: add linux-type limiting capability */
+
if(bChDirRoot) {
if(chdir("/") != 0)
fprintf(stderr, "Can not do 'cd /' - still trying to run\n");