From 16d600c0350a79c2532c739dd1432f7ed318ea09 Mon Sep 17 00:00:00 2001 From: William King Date: Fri, 4 Sep 2015 14:45:37 -0700 Subject: [PATCH] FS-8075 updates for limit release case --- src/mod/applications/mod_hiredis/TODO | 1 + src/mod/applications/mod_hiredis/mod_hiredis.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mod/applications/mod_hiredis/TODO b/src/mod/applications/mod_hiredis/TODO index 9966f0c7a0..08d8c0a032 100644 --- a/src/mod/applications/mod_hiredis/TODO +++ b/src/mod/applications/mod_hiredis/TODO @@ -2,5 +2,6 @@ 2. add lock for hiredis_profile for destroy vs running commands 3. Look into refactor/cleanup of xml processing 4. Add tab complete for profile names for APIs, and possibly for supported actions(and in theory look into key listing from redis) +5. Add linked list session pvt structure for keeping track of limit incr's on a session by session basis diff --git a/src/mod/applications/mod_hiredis/mod_hiredis.c b/src/mod/applications/mod_hiredis/mod_hiredis.c index f5cc90f5f3..1178ba4e89 100644 --- a/src/mod/applications/mod_hiredis/mod_hiredis.c +++ b/src/mod/applications/mod_hiredis/mod_hiredis.c @@ -93,7 +93,7 @@ SWITCH_STANDARD_API(raw_api) data++; } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "hiredis: debug: profile[%s] for command [%s]\n", input, data); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "hiredis: debug: profile[%s] for command [%s]\n", input, data); profile = switch_core_hash_find(mod_hiredis_globals.profiles, input); @@ -127,7 +127,7 @@ SWITCH_LIMIT_INCR(hiredis_limit_incr) time_t now = switch_epoch_time_now(NULL); switch_status_t status = SWITCH_STATUS_SUCCESS; - if ( !zstr(realm) ) { + if ( zstr(realm) ) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "hiredis: realm must be defined\n"); switch_goto_status(SWITCH_STATUS_GENERR, done); } @@ -185,6 +185,11 @@ SWITCH_LIMIT_RELEASE(hiredis_limit_release) switch_goto_status(SWITCH_STATUS_GENERR, done); } + if ( !realm && !resource ) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "hiredis does not yet support release on NULL realm[%s] and resource[%s]\n", realm, resource); + switch_goto_status(SWITCH_STATUS_GENERR, done); + } + hashkey = switch_mprintf("decr %s", resource); if ( hiredis_profile_execute_sync(profile, hashkey, &response) != SWITCH_STATUS_SUCCESS) {