#609 rl_dec_count increases counter

closed
None
5
2013-02-19
2013-02-07
Matt Williams
No

Calling rl_dec_count_increases the counter. Test calls rl_check 3 times to increment the counter.

#We're only checking our gateway rate limits here;
if(!rl_check("$avp(778)_$avp(271)", "$(avp(780){s.int})", "TAILDROP")) {
rl_check("$avp(778)_$avp(271)", "$(avp(780){s.int})", "TAILDROP");
rl_check("$avp(778)_$avp(271)", "$(avp(780){s.int})", "TAILDROP");
rl_dec_count("$avp(778)_$avp(271)");
rl_dec_count("$avp(778)_$avp(271)");
rl_dec_count("$avp(778)_$avp(271)");
#make sure counter doesn't go negative;
rl_dec_count("$avp(778)_$avp(271)");
route(route_failover);
exit;
}

Feb 7 13:02:22 [15173] DBG:ratelimit:w_rl_check_3: Pipe test doens't exist, but was created 0x2b4307eb2428
Feb 7 13:02:22 [15173] DBG:ratelimit:w_rl_check_3: Pipe test counter:1 load:0 limit:0 should be blocked (0x2b4307eb2428)
Feb 7 13:02:22 [15173] DBG:ratelimit:w_rl_check_3: Pipe test found: 0x2b4307eb2428 - last used 1360260142
Feb 7 13:02:22 [15173] DBG:ratelimit:w_rl_check_3: Pipe test counter:2 load:0 limit:0 should be blocked (0x2b4307eb2428)
Feb 7 13:02:22 [15173] DBG:ratelimit:w_rl_check_3: Pipe test found: 0x2b4307eb2428 - last used 1360260142
Feb 7 13:02:22 [15173] DBG:ratelimit:w_rl_check_3: Pipe test counter:3 load:0 limit:0 should be blocked (0x2b4307eb2428)
Feb 7 13:02:22 [15173] DBG:ratelimit:w_rl_set_count: new counter for key test is 4
Feb 7 13:02:22 [15173] DBG:ratelimit:w_rl_set_count: new counter for key test is 5
Feb 7 13:02:22 [15173] DBG:ratelimit:w_rl_set_count: new counter for key test is 6
Feb 7 13:02:22 [15173] DBG:ratelimit:w_rl_set_count: new counter for key test is 7

attached patch fixes my issues. Needs review to see if it breaks anything else.

Discussion

  • Matt Williams
    Matt Williams
    2013-02-07

     
  • Razvan Crainea
    Razvan Crainea
    2013-02-08

    Hi, Matt!

    Indeed, there was a bogus sign change issue related to the rl_dec_count function. I have fixed this on trunk, 1.9 and 1.8 versions. Let me know if there are any problems.

    Best regards,
    Răzvan

     
  • Matt Williams
    Matt Williams
    2013-02-08

    Thank You, I will test it out.

     
  • Matt Williams
    Matt Williams
    2013-02-08

    Looks like this allows it to go negative for one count.

    Feb 8 12:45:17 [12405] DBG:ratelimit:w_rl_check_3: Pipe test doens't exist, but was created 0x2b0d5fa7eee8
    Feb 8 12:45:17 [12405] DBG:ratelimit:w_rl_check_3: Pipe test counter:1 load:0 limit:0 should be blocked (0x2b0d5fa7eee8)
    Feb 8 12:45:17 [12405] DBG:ratelimit:w_rl_check_3: Pipe test found: 0x2b0d5fa7eee8 - last used 1360345517
    Feb 8 12:45:17 [12405] DBG:ratelimit:w_rl_check_3: Pipe test counter:2 load:0 limit:0 should be blocked (0x2b0d5fa7eee8)
    Feb 8 12:45:17 [12405] DBG:ratelimit:w_rl_check_3: Pipe test found: 0x2b0d5fa7eee8 - last used 1360345517
    Feb 8 12:45:17 [12405] DBG:ratelimit:w_rl_check_3: Pipe test counter:3 load:0 limit:0 should be blocked (0x2b0d5fa7eee8)
    Feb 8 12:45:17 [12405] DBG:ratelimit:w_rl_set_count: new counter for key test is 2
    Feb 8 12:45:17 [12405] DBG:ratelimit:w_rl_set_count: new counter for key test is 1
    Feb 8 12:45:17 [12405] DBG:ratelimit:w_rl_set_count: new counter for key test is 0
    Feb 8 12:45:17 [12405] DBG:ratelimit:w_rl_set_count: new counter for key test is -1
    Feb 8 12:45:17 [12405] DBG:ratelimit:w_rl_set_count: new counter for key test is 0

     
  • Razvan Crainea
    Razvan Crainea
    2013-02-10

    Hi, Matt!

    I have attached a new patch. Can you please give me a try and let me know how it works?

    Best regards,
    Răzvan

     
    • assigned_to: nobody --> razvancrainea
     
  • Razvan Crainea
    Razvan Crainea
    2013-02-15

    Hi, Matt!

    Any updates? Please let me know if everything is ok before I commit the fix.

    Best regards,
    Răzvan

     
  • Matt Williams
    Matt Williams
    2013-02-15

    My apologies I haven't had a chance to test. I will do so later today.

     
  • Matt Williams
    Matt Williams
    2013-02-18

    Looks like this patch works well. Thank you!

     
  • Razvan Crainea
    Razvan Crainea
    2013-02-19

    Hi, Matt!

    I've committed the fix on all branches. Thanks for reporting and for the tests. I will close this ticket.

    Best regards,
    Răzvan

     
  • Razvan Crainea
    Razvan Crainea
    2013-02-19

    • status: open --> closed