From: Brian West Date: Sat, 21 Mar 2009 02:34:37 +0000 (+0000) Subject: free handles in error and failure conditions X-Git-Tag: v1.0.4~1444 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de7a9798b600e59dd5d064a6991f0bf38ea64f54;p=thirdparty%2Ffreeswitch.git free handles in error and failure conditions git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12701 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 25a7a56a9d..3cdda830a1 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -333,6 +333,14 @@ void sofia_event_callback(nua_event_t event, int locked = 0; int check_destroy = 1; + if (nh && sofia_private == &mod_sofia_globals.keep_private) { + if (status >= 300) { + nua_handle_bind(nh, NULL); + nua_handle_destroy(nh); + return; + } + } + if (sofia_private && sofia_private != &mod_sofia_globals.destroy_private && sofia_private != &mod_sofia_globals.keep_private) { if ((gateway = sofia_private->gateway)) { if (switch_thread_rwlock_tryrdlock(gateway->profile->rwlock) != SWITCH_STATUS_SUCCESS) { diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 532a5b5a8c..d3820dc8ec 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -1405,6 +1405,7 @@ static int sofia_presence_mwi_callback2(void *pArg, int argc, char **argv, char } nh = nua_handle(profile->nua, NULL, NUTAG_URL(contact), SIPTAG_FROM_STR(id), SIPTAG_TO_STR(id), SIPTAG_CONTACT_STR(h->profile->url), TAG_END()); + nua_handle_bind(nh, &mod_sofia_globals.destroy_private); nua_notify(nh, NUTAG_NEWSUB(1),