[Freeswitch-svn] [commit] r8281 - freeswitch/trunk/src/mod/endpoints/mod_sofia
Freeswitch SVN
anthm at freeswitch.org
Tue May 6 18:56:56 EDT 2008
Author: anthm
Date: Tue May 6 18:56:55 2008
New Revision: 8281
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
Log:
fix possible register memory leak
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Tue May 6 18:56:55 2008
@@ -1899,6 +1899,7 @@
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);
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h Tue May 6 18:56:55 2008
@@ -100,6 +100,7 @@
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 @@
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;
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Tue May 6 18:56:55 2008
@@ -194,7 +194,7 @@
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 @@
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);
}
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c Tue May 6 18:56:55 2008
@@ -781,7 +781,8 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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),
More information about the Freeswitch-svn
mailing list