Merge pull request #852 in FS/freeswitch from ~MZAKA/freeswitch:bugfix/FS-9156-increments-when-call-limit-reached-improve to master

* commit 'f8b3140fed1650828d13349a7f9a63a73b29542e':
  FS-9156: Code Improvement for the non-interval increment when limit reached
This commit is contained in:
William King 2016-06-02 11:44:51 -05:00
commit d5e390aba5
1 changed files with 13 additions and 0 deletions

View File

@ -189,6 +189,19 @@ SWITCH_LIMIT_INCR(hiredis_limit_incr)
count = atoll(response ? response : ""); 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 ) { if ( !count || count > max ) {
switch_goto_status(SWITCH_STATUS_GENERR, done); switch_goto_status(SWITCH_STATUS_GENERR, done);
} }