fix possible register memory leak
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8281 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
b48ee12c1c
commit
a41fa2e2bc
|
@ -1899,6 +1899,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_sofia_load)
|
|||
silence_frame.flags = SFF_CNG;
|
||||
|
||||
memset(&mod_sofia_globals, 0, sizeof(mod_sofia_globals));
|
||||
mod_sofia_globals.destroy_private.destroy_nh = 1;
|
||||
mod_sofia_globals.pool = pool;
|
||||
switch_mutex_init(&mod_sofia_globals.mutex, SWITCH_MUTEX_NESTED, mod_sofia_globals.pool);
|
||||
|
||||
|
|
|
@ -100,6 +100,7 @@ struct sofia_private {
|
|||
char uuid[SWITCH_UUID_FORMATTED_LENGTH + 1];
|
||||
sofia_gateway_t *gateway;
|
||||
char gateway_name[512];
|
||||
int destroy_nh;
|
||||
};
|
||||
|
||||
#define set_param(ptr,val) if (ptr) {free(ptr) ; ptr = NULL;} if (val) {ptr = strdup(val);}
|
||||
|
@ -194,6 +195,7 @@ struct mod_sofia_globals {
|
|||
char guess_ip[80];
|
||||
switch_queue_t *presence_queue;
|
||||
switch_queue_t *mwi_queue;
|
||||
struct sofia_private destroy_private;
|
||||
};
|
||||
extern struct mod_sofia_globals mod_sofia_globals;
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ void sofia_event_callback(nua_event_t event,
|
|||
switch_channel_t *channel = NULL;
|
||||
sofia_gateway_t *gateway = NULL;
|
||||
|
||||
if (sofia_private) {
|
||||
if (sofia_private && sofia_private != &mod_sofia_globals.destroy_private) {
|
||||
if ((gateway = sofia_private->gateway)) {
|
||||
if (switch_thread_rwlock_tryrdlock(gateway->profile->rwlock) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile %s is locked\n", gateway->profile->name);
|
||||
|
@ -356,6 +356,11 @@ void sofia_event_callback(nua_event_t event,
|
|||
|
||||
done:
|
||||
|
||||
if (sofia_private && sofia_private->destroy_nh) {
|
||||
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Destroy handle requested.\n");
|
||||
nua_handle_destroy(nh);
|
||||
}
|
||||
|
||||
if (gateway) {
|
||||
sofia_reg_release_gateway(gateway);
|
||||
}
|
||||
|
|
|
@ -781,7 +781,8 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
|||
exptime = tmp - switch_timestamp(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//if (!(nh = nua_handle_by_call_id(profile->nua, call_id))) {
|
||||
if (!(nh = (nua_handle_t *) switch_core_hash_find(profile->sub_hash, call_id))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find handle for %s\n", call_id);
|
||||
return 0;
|
||||
|
@ -1045,7 +1046,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
|||
switch_snprintf(exp, sizeof(exp), "active;expires=%ld", (long) exptime);
|
||||
|
||||
nua_notify(nh,
|
||||
NUTAG_NEWSUB(1),
|
||||
//NUTAG_NEWSUB(1),
|
||||
SIPTAG_SUBSCRIPTION_STATE_STR(exp),
|
||||
SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR(ct), SIPTAG_PAYLOAD_STR(pl), TAG_END());
|
||||
|
||||
|
@ -1090,6 +1091,7 @@ static int sofia_presence_mwi_callback(void *pArg, int argc, char **argv, char *
|
|||
return 0;
|
||||
}
|
||||
|
||||
//if (!(nh = nua_handle_by_call_id(profile->nua, call_id))) {
|
||||
if (!(nh = (nua_handle_t *) switch_core_hash_find(profile->sub_hash, call_id))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot find handle for %s\n", call_id);
|
||||
return 0;
|
||||
|
@ -1103,7 +1105,7 @@ static int sofia_presence_mwi_callback(void *pArg, int argc, char **argv, char *
|
|||
exp = switch_mprintf("active;expires=%ld", expire_sec);
|
||||
|
||||
nua_notify(nh,
|
||||
NUTAG_NEWSUB(1),
|
||||
//NUTAG_NEWSUB(1),
|
||||
SIPTAG_SUBSCRIPTION_STATE_STR(exp),
|
||||
SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"), SIPTAG_PAYLOAD_STR(body), TAG_END());
|
||||
|
||||
|
@ -1146,6 +1148,7 @@ static int sofia_presence_mwi_callback2(void *pArg, int argc, char **argv, char
|
|||
SIPTAG_CONTACT_STR(profile->url),
|
||||
TAG_END());
|
||||
|
||||
nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
|
||||
nua_notify(nh,
|
||||
NUTAG_NEWSUB(1),
|
||||
SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"), SIPTAG_PAYLOAD_STR(body), TAG_END());
|
||||
|
@ -1347,6 +1350,7 @@ void sofia_presence_handle_sip_i_subscribe(int status,
|
|||
sent_reply++;
|
||||
|
||||
#if 0
|
||||
nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
|
||||
nua_notify(nh,
|
||||
NUTAG_NEWSUB(1),
|
||||
SIPTAG_SUBSCRIPTION_STATE_STR(sstr), SIPTAG_EVENT_STR(event),
|
||||
|
|
Loading…
Reference in New Issue