fixing two add for same termination back-2-back scenario, 2nd add should reject as term already in context

This commit is contained in:
root 2012-07-26 13:50:43 -04:00
parent ee8047ebbf
commit a6b85b7de5
6 changed files with 41 additions and 9 deletions

View File

@ -185,6 +185,7 @@ mg_termination_t *megaco_choose_termination(megaco_profile_t *profile, const cha
term->pool = pool;
term->type = termtype;
term->active_events = NULL;
term->mg_ctxt = NULL;
term->profile = profile;
switch_set_flag(term, MGT_ALLOCATED);
@ -231,6 +232,8 @@ void megaco_termination_destroy(mg_termination_t *term)
free(term->active_events);
term->active_events = NULL;
}
term->mg_ctxt = NULL;
switch_clear_flag(term, MGT_ALLOCATED);
switch_clear_flag(term, MGT_ACTIVE);

View File

@ -566,6 +566,10 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
goto error;
}
if(!term->mg_ctxt){
term->mg_ctxt = mg_ctxt;
}
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Allocated Termination[%p] with term name[%s]\n", (void*)term, term->name);
is_rtp = 0x01;
@ -580,6 +584,15 @@ switch_status_t handle_mg_add_cmd(megaco_profile_t* mg_profile, MgMgcoCommand *i
goto error;
}
if(!term->mg_ctxt){
term->mg_ctxt = mg_ctxt;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Termination[%s] already in context..rejecting ADD \n", term->name);
mg_util_set_err_string(&errTxt, " Term already is in call ");
err_code = MGT_MGCP_RSP_CODE_PROT_ERROR;
goto error;
}
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_INFO," Allocated Termination[%p] with term name[%s]\n", (void*)term, term->name);
}
/********************************************************************/

View File

@ -15,6 +15,11 @@
#define MG_INACTIVITY_TMR_RESOLUTION 100 /* mit in ito package is experessed in 10ms steps */
/* rtp/avp profiles */
#define MG_RTP_AVP_PROFILE_A_LAW 8
#define MG_RTP_AVP_PROFILE_U_LAW 0
typedef enum{
MG_SDP_NONE,
MG_SDP_LOCAL,

View File

@ -789,7 +789,7 @@ void mgco_print_CmSdpU8OrNil(CmSdpU8OrNil* p)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,"CmSdpU8OrNil: Value = %d \n", (NOTPRSNT != p->val.pres)?p->val.val:-1);
}
void mgco_print_sdp_media_param(CmSdpMedPar *s)
void mgco_print_sdp_media_param(CmSdpMedPar *s, mg_termination_t* term, mgco_sdp_types_e sdp_type)
{
int i=0x00;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "***** Media Parameter *********** \n");
@ -832,6 +832,12 @@ void mgco_print_sdp_media_param(CmSdpMedPar *s)
for(i=0;i<r->num.val;i++){
mgco_print_CmSdpU8OrNil(r->fmts[i]);
if(MG_RTP_AVP_PROFILE_A_LAW == r->fmts[i]->val.val){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, " MG_RTP_AVP_PROFILE_A_LAW: \n");
}else if(MG_RTP_AVP_PROFILE_U_LAW == r->fmts[i]->val.val){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, " MG_RTP_AVP_PROFILE_U_LAW: \n");
}
}
}
break;
@ -1074,7 +1080,7 @@ void mgco_handle_sdp(CmSdpInfoSet *sdp, mg_termination_t* term, mgco_sdp_types_e
break;
}
}
mgco_print_sdp_media_param(&f->par);
mgco_print_sdp_media_param(&f->par, term, sdp_type);
}
/*info */

View File

@ -99,6 +99,8 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload)
term->pool = pool;
term->type = MG_TERM_TDM;
term->profile = profile;
term->mg_ctxt = NULL;
term->active_events = NULL;
term->name = switch_core_sprintf(pool, "%s%d", prefix, j);
term->u.tdm.channel = j;
term->u.tdm.span_name = switch_core_strdup(pool, channel_prefix);

View File

@ -94,6 +94,14 @@ enum {
} mg_termination_flags;
struct mg_context_s {
uint32_t context_id;
mg_termination_t *terminations[MG_CONTEXT_MAX_TERMS];
megaco_profile_t *profile;
mg_context_t *next;
switch_memory_pool_t *pool;
};
struct mg_termination_s {
switch_memory_pool_t *pool;
mg_termination_type_t type;
@ -104,6 +112,7 @@ struct mg_termination_s {
MgMgcoReqEvtDesc *active_events; /* !< active megaco events */
mg_termination_t *next; /*!< List for physical terminations */
uint32_t flags;
mg_context_t* mg_ctxt;
union {
struct {
@ -131,13 +140,7 @@ struct mg_termination_s {
};
struct mg_context_s {
uint32_t context_id;
mg_termination_t *terminations[MG_CONTEXT_MAX_TERMS];
megaco_profile_t *profile;
mg_context_t *next;
switch_memory_pool_t *pool;
};
#define MG_CONTEXT_MODULO 16
#define MG_MAX_CONTEXTS 32768