]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-8978: [mod_redis] Fix limit counter not decrementing on hangup
authorPhil Lavin <phil.lavin@synety.com>
Thu, 24 Mar 2016 18:34:13 +0000 (18:34 +0000)
committerPhil Lavin <phil@lavin.me.uk>
Thu, 24 Mar 2016 18:38:07 +0000 (18:38 +0000)
The limit counter value is not automatically decremented in Redis when
the call is hung up. This results in it only ever counting up and the
limit being eventually hit.

The linked list is moved on too early. When `limit_pvt` is checked, it
is `NULL`. This means the `decr` command is never sent to Redis.

src/mod/applications/mod_hiredis/mod_hiredis.c

index 09a538e15a736b74a8bee555e8d8bf4e23c6155a..2af3cd359830746b37b81b54c27cf6bc99a832e4 100644 (file)
@@ -197,13 +197,14 @@ SWITCH_LIMIT_RELEASE(hiredis_limit_release)
                while (tmp) {
                        profile = switch_core_hash_find(mod_hiredis_globals.profiles, limit_pvt->realm);
                        hashkey = switch_mprintf("decr %s", tmp->limit_key);
-                       limit_pvt = tmp->next;
 
                        if ( limit_pvt && (limit_pvt->interval > 0) && (hiredis_profile_execute_sync(profile, hashkey, &response) != SWITCH_STATUS_SUCCESS)) {
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "hiredis: profile[%s] error executing [%s] because [%s]\n",
                                                                  tmp->realm, hashkey, response);
                        }
 
+                       limit_pvt = tmp->next;
+
                        tmp = limit_pvt;
                        switch_safe_free(response);
                        switch_safe_free(hashkey);