summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-04-27 10:09:15 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2011-04-27 10:09:15 +0200
commit24b62834801043bf2d9560b0cca3967e5762bea1 (patch)
tree56af4108541a9deb95df720bae28627101f6fcfd
parent7420dd6c2f68fc1abcce9fb2076d3aadc92cbffc (diff)
downloadrsyslog-24b62834801043bf2d9560b0cca3967e5762bea1.tar.gz
rsyslog-24b62834801043bf2d9560b0cca3967e5762bea1.tar.xz
rsyslog-24b62834801043bf2d9560b0cca3967e5762bea1.zip
bugfix: rate-limiting inside imuxsock did not work 100% correct
reason was that a global config variable was invalidly accessed where a listener variable should have been used. Also performance-improved the case when rate limiting is turned off (this is a very unintrusive change, thus done directly to the stable version).
-rw-r--r--ChangeLog5
-rw-r--r--plugins/imuxsock/imuxsock.c9
2 files changed, 12 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 4a46b2c9..48b58a9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
---------------------------------------------------------------------------
Version 5.8.1 [V5-stable] (rgerhards), 2011-04-??
+- bugfix: rate-limiting inside imuxsock did not work 100% correct
+ reason was that a global config variable was invalidly accessed where a
+ listener variable should have been used.
+ Also performance-improved the case when rate limiting is turned off (this
+ is a very unintrusive change, thus done directly to the stable version).
- bugfix: $myhostname not available in RainerScript (and no error message)
closes: http://bugzilla.adiscon.com/show_bug.cgi?id=233
- bugfix: doc for impstats had wrong config statements
diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c
index 86393ba6..af034b9f 100644
--- a/plugins/imuxsock/imuxsock.c
+++ b/plugins/imuxsock/imuxsock.c
@@ -432,7 +432,8 @@ finalize_it:
/* find ratelimiter to use for this message. Currently, we use the
* pid, but may change to cgroup later (probably via a config switch).
- * Returns NULL if not found.
+ * Returns NULL if not found or rate-limiting not activated for this
+ * listener (the latter being a performance enhancement).
*/
static inline rsRetVal
findRatelimiter(lstn_t *pLstn, struct ucred *cred, rs_ratelimit_state_t **prl)
@@ -444,6 +445,10 @@ findRatelimiter(lstn_t *pLstn, struct ucred *cred, rs_ratelimit_state_t **prl)
if(cred == NULL)
FINALIZE;
+ if(pLstn->ratelimitInterval == 0) {
+ *prl = NULL;
+ FINALIZE;
+ }
rl = hashtable_search(pLstn->ht, &cred->pid);
if(rl == NULL) {
@@ -454,7 +459,7 @@ findRatelimiter(lstn_t *pLstn, struct ucred *cred, rs_ratelimit_state_t **prl)
CHKmalloc(rl = malloc(sizeof(rs_ratelimit_state_t)));
CHKmalloc(keybuf = malloc(sizeof(pid_t)));
*keybuf = cred->pid;
- initRatelimitState(rl, ratelimitInterval, pLstn->ratelimitBurst);
+ initRatelimitState(rl, pLstn->ratelimitInterval, pLstn->ratelimitBurst);
r = hashtable_insert(pLstn->ht, keybuf, rl);
if(r == 0)
ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);