summaryrefslogtreecommitdiffstats
path: root/runtime/ratelimit.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2013-06-17 14:19:34 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2013-06-17 14:19:34 +0200
commitfa523900ba66cda045d16476d64fd89d8d6f0bdc (patch)
treedc5f867dea9c7ab42b1845992a3a8f21fb7b3d25 /runtime/ratelimit.c
parentba4caf70560b5fd23fc2e1624b52f78784ce5b59 (diff)
parent1f6d402d50501bc612eb5041ed0674eb23432166 (diff)
downloadrsyslog-fa523900ba66cda045d16476d64fd89d8d6f0bdc.tar.gz
rsyslog-fa523900ba66cda045d16476d64fd89d8d6f0bdc.tar.bz2
rsyslog-fa523900ba66cda045d16476d64fd89d8d6f0bdc.zip
Merge branch 'v7-stable'
Diffstat (limited to 'runtime/ratelimit.c')
-rw-r--r--runtime/ratelimit.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/runtime/ratelimit.c b/runtime/ratelimit.c
index 6e1df3e2..a808e04a 100644
--- a/runtime/ratelimit.c
+++ b/runtime/ratelimit.c
@@ -150,12 +150,21 @@ withinRatelimit(ratelimit_t *ratelimit, time_t tt)
goto finalize_it;
}
+ /* we primarily need "NoTimeCache" mode for imjournal, as it
+ * sets the message generation time to the journal timestamp.
+ * As such, we do not get a proper indication of the actual
+ * message rate. To prevent this, we need to query local
+ * system time ourselvs.
+ */
+ if(ratelimit->bNoTimeCache)
+ tt = time(NULL);
+
assert(ratelimit->burst != 0);
if(ratelimit->begin == 0)
ratelimit->begin = tt;
- /* resume if we go out of out time window */
+ /* resume if we go out of time window */
if(tt > ratelimit->begin + ratelimit->interval) {
ratelimit->begin = 0;
ratelimit->done = 0;
@@ -318,6 +327,12 @@ ratelimitSetThreadSafe(ratelimit_t *ratelimit)
ratelimit->bThreadSafe = 1;
pthread_mutex_init(&ratelimit->mut, NULL);
}
+void
+ratelimitSetNoTimeCache(ratelimit_t *ratelimit)
+{
+ ratelimit->bNoTimeCache = 1;
+ pthread_mutex_init(&ratelimit->mut, NULL);
+}
/* Severity level determines which messages are subject to
* ratelimiting. Default (no value set) is all messages.
@@ -368,4 +383,3 @@ ratelimitModInit(void)
finalize_it:
RETiRet;
}
-