Skip to content

Commit

Permalink
ratelimit: don't add json object if map is empty
Browse files Browse the repository at this point in the history
An object map was added for each hash entry, even though there were no
pipes in that hash, resulting in a huge list of empty hashes [{},{} ...]
This fix does not add an object in the resulted array if the map is
empty.

(cherry picked from commit a37642a)
  • Loading branch information
razvancrainea committed Oct 9, 2019
1 parent bfc7f12 commit 18035f4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modules/ratelimit/ratelimit_helper.c
Expand Up @@ -611,6 +611,8 @@ int rl_stats(mi_item_t *resp_obj, str * value)
if (!pipe_arr)
return -1;
for (i = 0; i < rl_htable.size; i++) {
if (map_size(rl_htable.maps[i]) == 0)
continue;
pipe_item = add_mi_object(pipe_arr, NULL, 0);
if (!pipe_item)
return -1;
Expand Down

0 comments on commit 18035f4

Please sign in to comment.