One segfault and one minor fix. Both related to logging internal messages in the ratelimiter before reseting its state.

Tomas
>From 82db8e6fbba89bf486cc7e642e4f8daaa43852e8 Mon Sep 17 00:00:00 2001
From: Tomas Heinrich <[email protected]>
Date: Mon, 10 Jun 2013 23:09:38 +0200
Subject: [PATCH] bugfix: prevent another endless loop in the ratelimiter

The message that reports how many messages were lost due to
ratelimiting was sent before reseting the state that led to it. If it
itself got ratelimited, this could lead to an endless loop.
---
 runtime/ratelimit.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/runtime/ratelimit.c b/runtime/ratelimit.c
index ec24855..443a5fa 100644
--- a/runtime/ratelimit.c
+++ b/runtime/ratelimit.c
@@ -128,8 +128,8 @@ tellLostCnt(ratelimit_t *ratelimit)
 		snprintf((char*)msgbuf, sizeof(msgbuf),
 			 "%s: %u messages lost due to rate-limiting",
 			 ratelimit->name, ratelimit->missed);
-		logmsgInternal(RS_RET_RATE_LIMITED, LOG_SYSLOG|LOG_INFO, msgbuf, 0);
 		ratelimit->missed = 0;
+		logmsgInternal(RS_RET_RATE_LIMITED, LOG_SYSLOG|LOG_INFO, msgbuf, 0);
 	}
 }
 
-- 
1.7.10.4

>From 489541d2a901c5fedd9cbbdc8ad0df557fdabddd Mon Sep 17 00:00:00 2001
From: Tomas Heinrich <[email protected]>
Date: Tue, 11 Jun 2013 16:27:37 +0200
Subject: [PATCH] bugfix: prevent calling tellLostCnt() twice

---
 runtime/ratelimit.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/runtime/ratelimit.c b/runtime/ratelimit.c
index ec24855..8f5bcef 100644
--- a/runtime/ratelimit.c
+++ b/runtime/ratelimit.c
@@ -157,9 +157,9 @@ withinRatelimit(ratelimit_t *ratelimit, time_t tt)
 
 	/* resume if we go out of out time window */
 	if(tt > ratelimit->begin + ratelimit->interval) {
-		tellLostCnt(ratelimit);
 		ratelimit->begin = 0;
 		ratelimit->done = 0;
+		tellLostCnt(ratelimit);
 	}
 
 	/* do actual limit check */
-- 
1.7.10.4

_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of 
sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE 
THAT.

Reply via email to