]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-9156: Code Improvement for the non-interval increment when limit reached
authorMuhammad Zaka <muhammad.zaka@synety.com>
Fri, 13 May 2016 10:18:25 +0000 (11:18 +0100)
committerMuhammad Zaka <muhammad.zaka@synety.com>
Thu, 2 Jun 2016 08:57:17 +0000 (09:57 +0100)
src/mod/applications/mod_hiredis/mod_hiredis.c

index 9536521899f98b33151a3aa15e38e948878e4d5c..a81f86f8ff4106d52ac2404c25779fdde24b0057 100644 (file)
@@ -189,6 +189,19 @@ SWITCH_LIMIT_INCR(hiredis_limit_incr)
 
        count = atoll(response ? response : "");
 
+       if (!interval && count > max ) {
+               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "%s is already at max value (%d)\n", limit_key , max);
+               switch_safe_free(hashkey);
+               switch_safe_free(response);
+               hashkey = switch_mprintf("decr %s", limit_key);
+               if ( (status = hiredis_profile_execute_sync(profile, hashkey, &response, session)) != SWITCH_STATUS_SUCCESS ) {
+                       if ( status == SWITCH_STATUS_SOCKERR && profile->ignore_connect_fail ) {
+                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "hiredis: profile[%s] connection error executing [%s] with limit already reached\n", realm, hashkey);
+                               switch_goto_status(SWITCH_STATUS_SUCCESS, done); // increment has been succesful but decrement have failed
+                       }
+               }
+       }
+
        if ( !count || count > max ) {
                switch_goto_status(SWITCH_STATUS_GENERR, done);
        }