Skip to content

Commit

Permalink
ratelimit: replicate the current counter for SBT
Browse files Browse the repository at this point in the history
  • Loading branch information
razvancrainea committed Feb 1, 2018
1 parent 2e24c55 commit 08bc179
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion modules/ratelimit/ratelimit_helper.c
Expand Up @@ -1020,7 +1020,13 @@ void rl_timer_repl(utime_t ticks, void *param)
if (bin_push_int(&packet, (*pipe)->limit) < 0)
goto error;

if ((ret = bin_push_int(&packet, (*pipe)->my_last_counter)) < 0)
/*
* for the SBT algorithm it is safe to replicate the current
* counter, since it is always updating according to the window
*/
if ((ret = bin_push_int(&packet,
((*pipe)->algo == PIPE_ALGO_HISTORY ?
(*pipe)->counter : (*pipe)->my_last_counter))) < 0)
goto error;
nr++;

Expand Down

0 comments on commit 08bc179

Please sign in to comment.