From f11a873dc4e258c346765af9d5d23a1180493ee8 Mon Sep 17 00:00:00 2001 From: Tomas Heinrich Date: Sat, 8 Jun 2013 23:27:48 +0200 Subject: [PATCH 2/2] bugfix: prevent an endless loop in the ratelimiter If messages are being dropped because of ratelimiting, an internal message is generated to inform about this fact. This should happen only uppon the firs occurance but the counter that tracks the number of dropped messages was incremented only after sending the message. If the message itself gets ratelimited, an endless loop spins out of control. Thanks to Jerry James for notifying about this. --- runtime/ratelimit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/ratelimit.c b/runtime/ratelimit.c index d83da2d..ec24855 100644 --- a/runtime/ratelimit.c +++ b/runtime/ratelimit.c @@ -167,13 +167,13 @@ withinRatelimit(ratelimit_t *ratelimit, time_t tt) ratelimit->done++; ret = 1; } else { - if(ratelimit->missed == 0) { + ratelimit->missed++; + if(ratelimit->missed == 1) { snprintf((char*)msgbuf, sizeof(msgbuf), "%s: begin to drop messages due to rate-limiting", ratelimit->name); logmsgInternal(RS_RET_RATE_LIMITED, LOG_SYSLOG|LOG_INFO, msgbuf, 0); } - ratelimit->missed++; ret = 0; } -- 1.7.10.4