Rework rate limit to only refill when needed

This commit is contained in:
Nils O. Selåsdal
2013-10-16 19:22:53 +02:00
parent 2d680052b2
commit 262958b8a0
3 changed files with 49 additions and 49 deletions
+3 -4
View File
@@ -65,8 +65,8 @@ struct RateLimit {
* @param tickets number of tickets (bucket depth)
* @param period per this period
*/
#define UC_RATELIMIT_INITIALIZER(tickets, period)\
{ tickets, period, tickets * period, 0}
#define UC_RATELIMIT_INITIALIZER(tickets)\
{ tickets, period, 0, -period}
@@ -79,9 +79,8 @@ struct RateLimit {
* @param r RateLimit to initialize
* @param tickets number of tickets (bucket depth)
* @param period per this period
* @param current_ts the current timestamp
*/
void uc_ratelimit_init(struct RateLimit *r, long tickets, long period, long current_ts);
void uc_ratelimit_init(struct RateLimit *r, long tickets, long period);
/**
* Reset a RateLimit, filling up the tickets again.