From: Kapil Gupta Date: Thu, 6 Sep 2012 15:52:23 +0000 (-0400) Subject: temp fix - calling mg_choose_context api again if failure in first attempt X-Git-Tag: v1.2.3^2~71^2^2~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b285155449e6c294d63d15a5f1cf05671d70a9f4;p=thirdparty%2Ffreeswitch.git temp fix - calling mg_choose_context api again if failure in first attempt --- diff --git a/src/mod/endpoints/mod_media_gateway/media_gateway_cmd_handler.c b/src/mod/endpoints/mod_media_gateway/media_gateway_cmd_handler.c index 9ed09d8b7b..1268660d82 100644 --- a/src/mod/endpoints/mod_media_gateway/media_gateway_cmd_handler.c +++ b/src/mod/endpoints/mod_media_gateway/media_gateway_cmd_handler.c @@ -631,13 +631,19 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i mg_ctxt = megaco_choose_context(mg_profile); - if(NULL == mg_ctxt){ - mg_profile->mg_stats->total_num_of_choose_ctxt_failed_error++; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR," megaco_choose_context failed \n"); - mg_util_set_err_string(&errTxt, " Resource Failure "); - err_code = MGT_MGCO_RSP_CODE_RSRC_ERROR; - goto error; - } + if(NULL == mg_ctxt){ + /* temp fix - Calling again, just in case if this time we get context */ + mg_ctxt = megaco_choose_context(mg_profile); + if(NULL == mg_ctxt){ + mg_profile->mg_stats->total_num_of_choose_ctxt_failed_error++; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR," megaco_choose_context failed \n"); + mg_util_set_err_string(&errTxt, " Resource Failure "); + err_code = MGT_MGCO_RSP_CODE_RSRC_ERROR; + goto error; + }else{ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR," megaco_choose_context - Success in 2nd Attempt \n"); + } + } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO," Allocated Context[%p] with context_id[%d]\n", (void*)mg_ctxt, mg_ctxt->context_id);