summaryrefslogtreecommitdiffstats
path: root/runtime/ratelimit.c
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/ratelimit.c')
-rw-r--r--runtime/ratelimit.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/runtime/ratelimit.c b/runtime/ratelimit.c
index d83da2dd..6e1df3e2 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);
}
}
@@ -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 */
@@ -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;
}