summaryrefslogtreecommitdiff
path: root/runtime/ratelimit.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2013-04-23 13:55:44 +0200
committerMichael Biebl <biebl@debian.org>2013-04-23 13:55:44 +0200
commitbd9408b88c40fb9a7dc88f4b2b6f218fcb17a388 (patch)
tree8c6f71d9e7c1152679a460e6f5ddda945608a78a /runtime/ratelimit.c
parent79b9293acbb763ad949ed7878f138f424dfa85ac (diff)
downloadrsyslog-bd9408b88c40fb9a7dc88f4b2b6f218fcb17a388.tar.gz
Imported Upstream version 7.3.11upstream/7.3.11
Diffstat (limited to 'runtime/ratelimit.c')
-rw-r--r--runtime/ratelimit.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/runtime/ratelimit.c b/runtime/ratelimit.c
index 4b618fb..d83da2d 100644
--- a/runtime/ratelimit.c
+++ b/runtime/ratelimit.c
@@ -202,7 +202,9 @@ ratelimitMsg(ratelimit_t *ratelimit, msg_t *pMsg, msg_t **ppRepMsg)
DEFiRet;
*ppRepMsg = NULL;
- if(ratelimit->interval) {
+ /* Only the messages having severity level at or below the
+ * treshold (the value is >=) are subject to ratelimiting. */
+ if(ratelimit->interval && (pMsg->iSeverity >= ratelimit->severity)) {
if(withinRatelimit(ratelimit, pMsg->ttGenTime) == 0) {
msgDestruct(&pMsg);
ABORT_FINALIZE(RS_RET_DISCARDMSG);
@@ -284,6 +286,7 @@ ratelimitNew(ratelimit_t **ppThis, char *modname, char *dynname)
namebuf[sizeof(namebuf)-1] = '\0'; /* to be on safe side */
pThis->name = strdup(namebuf);
}
+ /* pThis->severity == 0 - all messages are ratelimited */
pThis->bReduceRepeatMsgs = loadConf->globals.bReduceRepeatMsgs;
*ppThis = pThis;
finalize_it:
@@ -316,6 +319,15 @@ ratelimitSetThreadSafe(ratelimit_t *ratelimit)
pthread_mutex_init(&ratelimit->mut, NULL);
}
+/* Severity level determines which messages are subject to
+ * ratelimiting. Default (no value set) is all messages.
+ */
+void
+ratelimitSetSeverity(ratelimit_t *ratelimit, intTiny severity)
+{
+ ratelimit->severity = severity;
+}
+
void
ratelimitDestruct(ratelimit_t *ratelimit)
{