adding mg and peer profile cleanup code during shutdown and removing

"unused variables" warnings
This commit is contained in:
kapil 2012-06-25 12:12:04 +05:30
parent fa616a377b
commit e3eed73ecb
4 changed files with 59 additions and 6 deletions

View File

@ -107,6 +107,21 @@ switch_status_t megaco_profile_destroy(megaco_profile_t **profile)
return SWITCH_STATUS_SUCCESS;
}
switch_status_t megaco_peer_profile_destroy(mg_peer_profile_t **profile)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stopping peer profile: %s\n", (*profile)->name);
switch_core_hash_delete_wrlock(megaco_globals.peer_profile_hash, (*profile)->name, megaco_globals.peer_profile_rwlock);
mg_peer_config_cleanup(*profile);
switch_core_destroy_memory_pool(&(*profile)->pool);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stopped peer profile: %s\n", (*profile)->name);
return SWITCH_STATUS_SUCCESS;
}
/* For Emacs:
* Local Variables:
* mode:c

View File

@ -133,6 +133,15 @@ switch_status_t mg_config_cleanup(megaco_profile_t* profile)
return SWITCH_STATUS_SUCCESS;
}
/****************************************************************************************************************************/
switch_status_t mg_peer_config_cleanup(mg_peer_profile_t* profile)
{
switch_xml_config_item_t *instructions = (profile ? get_peer_instructions(profile) : NULL);
switch_xml_config_cleanup(instructions);
return SWITCH_STATUS_SUCCESS;
}
/****************************************************************************************************************************/
static switch_xml_config_item_t *get_peer_instructions(mg_peer_profile_t *profile) {
switch_xml_config_item_t *dup;

View File

@ -97,6 +97,32 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_media_gateway_load)
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_media_gateway_shutdown)
{
void *val = NULL;
const void *key = NULL;
switch_ssize_t keylen;
switch_hash_index_t *hi = NULL;
megaco_profile_t* profile = NULL;
mg_peer_profile_t* peer_profile = NULL;
/* destroy all the mg profiles */
while ((hi = switch_hash_first(NULL, megaco_globals.profile_hash))) {
switch_hash_this(hi, &key, &keylen, &val);
profile = (megaco_profile_t *) val;
megaco_profile_destroy(&profile);
profile = NULL;
}
hi = NULL;
key = NULL;
val = NULL;
/* destroy all the mg peer profiles */
while ((hi = switch_hash_first(NULL, megaco_globals.peer_profile_hash))) {
switch_hash_this(hi, &key, &keylen, &val);
peer_profile = (mg_peer_profile_t *) val;
megaco_peer_profile_destroy(&peer_profile);
peer_profile = NULL;
}
sng_mgco_stack_shutdown();
return SWITCH_STATUS_SUCCESS;
@ -156,7 +182,7 @@ static void mgco_print_sdp(CmSdpInfoSet *sdp)
}
if (s->attrSet.numComp.pres) {
for (mediaId = 0; mediaId < s->attrSet.numComp.val; mediaId++) {
CmSdpAttr *a = s->attrSet.attr[mediaId];
/*CmSdpAttr *a = s->attrSet.attr[mediaId];*/
}
@ -221,9 +247,10 @@ void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg)
/* Loop over command list */
for (cmdIter=0; cmdIter < (actnReq->cl.num.val); cmdIter++) {
MgMgcoCommandReq *cmdReq = actnReq->cl.cmds[cmdIter];
MgMgcoTermId *termId = NULLP;
/*MgMgcoTermId *termId = NULLP;*/
/* The reply we'll send */
MgMgcoCommand mgCmd = {0};
MgMgcoCommand mgCmd;
memset(&mgCmd, 0, sizeof(mgCmd));
mgCmd.peerId = msg->lcl.id;
mgCmd.transId = transId;
mgCmd.u.mgCmdInd[0] = cmdReq;
@ -328,18 +355,18 @@ void handle_mgco_txn_ind(Pst *pst, SuId suId, MgMgcoMsg* msg)
}
case MGT_MODIFY:
{
MgMgcoAmmReq *addReq = &cmdReq->cmd.u.mod;
/*MgMgcoAmmReq *addReq = &cmdReq->cmd.u.mod;*/
break;
}
case MGT_MOVE:
{
MgMgcoAmmReq *addReq = &cmdReq->cmd.u.move;
/*MgMgcoAmmReq *addReq = &cmdReq->cmd.u.move;*/
break;
}
case MGT_SUB:
{
MgMgcoSubAudReq *addReq = &cmdReq->cmd.u.sub;
/*MgMgcoSubAudReq *addReq = &cmdReq->cmd.u.sub;*/
}
case MGT_SVCCHG:
case MGT_NTFY:

View File

@ -84,6 +84,8 @@ switch_status_t config_profile(megaco_profile_t *profile, switch_bool_t reload);
switch_status_t sng_mgco_start(megaco_profile_t* profile);
switch_status_t sng_mgco_stop(megaco_profile_t* profile);
switch_status_t mg_config_cleanup(megaco_profile_t* profile);
switch_status_t mg_peer_config_cleanup(mg_peer_profile_t* profile);
switch_status_t megaco_peer_profile_destroy(mg_peer_profile_t **profile);
switch_status_t mg_process_cli_cmd(const char *cmd, switch_stream_handle_t *stream);