diff --git a/src/mod/endpoints/mod_sofia/Makefile.am b/src/mod/endpoints/mod_sofia/Makefile.am index dc1ef1f793..5825fc7f5c 100644 --- a/src/mod/endpoints/mod_sofia/Makefile.am +++ b/src/mod/endpoints/mod_sofia/Makefile.am @@ -10,7 +10,7 @@ SOFIALA=$(SOFIAUA_BUILDDIR)/libsofia-sip-ua.la mod_LTLIBRARIES = mod_sofia.la mod_sofia_la_SOURCES = mod_sofia.c sofia.c sofia_glue.c sofia_presence.c sofia_reg.c sofia_sla.c sip-dig.c mod_sofia.h -mod_sofia_la_CFLAGS = $(AM_CFLAGS) -I. +mod_sofia_la_CFLAGS = $(AM_CFLAGS) -I. $(SOFIA_CMD_LINE_CFLAGS) mod_sofia_la_CFLAGS += -I$(SOFIAUA_DIR)/bnf -I$(SOFIAUA_BUILDDIR)/bnf mod_sofia_la_CFLAGS += -I$(SOFIAUA_DIR)/http -I$(SOFIAUA_BUILDDIR)/http mod_sofia_la_CFLAGS += -I$(SOFIAUA_DIR)/iptsec -I$(SOFIAUA_BUILDDIR)/iptsec diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 43ce1a312a..accc14657d 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -553,8 +553,9 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session) *tech_pvt->sofia_private->uuid = '\0'; } + sofia_glue_set_rtp_stats(tech_pvt); - + switch_mutex_unlock(tech_pvt->sofia_mutex); return SWITCH_STATUS_SUCCESS; diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index a9a755efa8..0e1a70e11d 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -33,7 +33,7 @@ * mod_sofia.h -- SOFIA SIP Endpoint * */ -//#define HAVE_MEMLEAK_LOG 1 + /*Defines etc..*/ /*************************************************************************************************************************************************************/ #define MANUAL_BYE 1 @@ -151,12 +151,10 @@ struct sofia_private { char gateway_name[256]; char auth_gateway_name[256]; int destroy_nh; + int destroy_me; int is_call; - int got_bye; int is_static; sofia_dispatch_event_t *de; - nua_handle_t *nh; - sofia_profile_t *profile; }; #define set_param(ptr,val) if (ptr) {free(ptr) ; ptr = NULL;} if (val) {ptr = strdup(val);} @@ -320,7 +318,7 @@ typedef enum { } TFLAGS; #define SOFIA_MAX_MSG_QUEUE 51 -#define SOFIA_MSG_QUEUE_SIZE 200 +#define SOFIA_MSG_QUEUE_SIZE 1000 struct mod_sofia_globals { switch_memory_pool_t *pool; @@ -618,7 +616,6 @@ struct sofia_profile { uint32_t event_timeout; int watchdog_enabled; switch_mutex_t *gw_mutex; - switch_queue_t *nh_destroy_queue; }; struct private_object { @@ -1126,6 +1123,3 @@ char *sofia_glue_gen_contact_str(sofia_profile_t *profile, sip_t const *sip, sof void sofia_glue_pause_jitterbuffer(switch_core_session_t *session, switch_bool_t on); void sofia_process_dispatch_event(sofia_dispatch_event_t **dep); -int sofia_nua_handle_destroy_run(switch_queue_t *q); -void sofia_nua_handle_destroy(switch_queue_t *q, nua_handle_t **nhp); - diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 9e7f54a51f..33fe189f94 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -486,7 +486,12 @@ void sofia_handle_sip_i_notify(switch_core_session_t *session, int status, end: - return; + if (sub_state == nua_substate_terminated && sofia_private && sofia_private != &mod_sofia_globals.destroy_private && + sofia_private != &mod_sofia_globals.keep_private) { + sofia_private->destroy_nh = 1; + sofia_private->destroy_me = 1; + } + } void sofia_handle_sip_i_bye(switch_core_session_t *session, int status, @@ -553,9 +558,13 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status, switch_channel_hangup(channel, cause); nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)), TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END()); - + switch_safe_free(extra_headers); + if (sofia_private) { + sofia_private->destroy_me = 1; + sofia_private->destroy_nh = 1; + } #endif @@ -576,8 +585,6 @@ void sofia_handle_sip_i_bye(switch_core_session_t *session, int status, } tech_pvt->got_bye = 1; - sofia_private->got_bye = 1; - switch_channel_set_variable(channel, "sip_hangup_disposition", "recv_bye"); return; @@ -1069,7 +1076,6 @@ static void our_sofia_event_callback(nua_event_t event, if (check_destroy) { if (nh && ((sofia_private && sofia_private->destroy_nh) || !nua_handle_magic(nh))) { - if (sofia_private) { nua_handle_bind(nh, NULL); } @@ -1079,6 +1085,19 @@ static void our_sofia_event_callback(nua_event_t event, } } + if (sofia_private && sofia_private->destroy_me) { + if (tech_pvt) { + tech_pvt->sofia_private = NULL; + } + + if (nh) { + nua_handle_bind(nh, NULL); + } + sofia_private->destroy_me = 12; + sofia_private_free(sofia_private); + + } + if (gateway) { sofia_reg_release_gateway(gateway); } @@ -1092,99 +1111,22 @@ static void our_sofia_event_callback(nua_event_t event, } } -int sofia_nua_handle_destroy_run(switch_queue_t *q) -{ - void *pop; - int i = 0; - uint32_t ttl; - - ttl = switch_queue_size(q); - - while(i < ttl && switch_queue_trypop(q, &pop) == SWITCH_STATUS_SUCCESS && pop) { - nua_handle_t *nh = (nua_handle_t *) pop; - int x = su_home_refcount((su_home_t *)nh) - 1; -#ifdef DEBUG_CONN - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "DESTROY %p\n", (void *) nh); -#endif - - if (x == 1) { - nua_handle_destroy(nh); - } else { -#ifdef DEBUG_CONN - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "DOH REQUEUE %p\n", (void *) nh); -#endif - switch_queue_push(q, nh); - } - nh = NULL; - i++; - } - - return i; -} - -void sofia_nua_handle_destroy(switch_queue_t *q, nua_handle_t **nhp) -{ - nua_handle_t *nh; - - switch_assert(nhp); - - nh = *nhp; - *nhp = NULL; - - if (nh) { - switch_queue_push(q, nh); - } -} - void sofia_process_dispatch_event(sofia_dispatch_event_t **dep) { sofia_dispatch_event_t *de = *dep; - nua_handle_t *nh = de->nh, *snh = NULL; + nua_handle_t *nh = de->nh; nua_t *nua = de->nua; - sofia_private_t *sofia_private = nua_handle_magic(de->nh); - int destroy = 0; - + *dep = NULL; - sofia_private = nua_handle_magic(nh); - - if (de->data->e_event == nua_i_terminated) { -#ifdef DEBUG_CONN - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "CATCH EVENT %s\n", nua_event_name(de->data->e_event)); -#endif - destroy = 1; - if (sofia_private && sofia_private->nh) { - snh = sofia_private->nh; - nua_handle_unref(nh); - } - } else { -#ifdef DEBUG_CONN - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "PROCESS EVENT %s\n", nua_event_name(de->data->e_event)); -#endif - our_sofia_event_callback(de->data->e_event, de->data->e_status, de->data->e_phrase, de->nua, de->profile, - nh, sofia_private, de->sip, de, (tagi_t *) de->data->e_tags); + de->nh, nua_handle_magic(de->nh), de->sip, de, (tagi_t *) de->data->e_tags); -#ifdef DEBUG_CONN - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "/PROCESS EVENT %s\n", nua_event_name(de->data->e_event)); -#endif - } - - nua_handle_unref(nh); - - nua_destroy_event(de->event); + nua_destroy_event(de->event); su_free(nh->nh_home, de); - - if (destroy && snh) { - nua_handle_bind(snh, NULL); -#ifdef DEBUG_CONN - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "go go UNREF %d\n", nh->nh_ref_by_user); -#endif - sofia_nua_handle_destroy(sofia_private->profile->nh_destroy_queue, &snh); - } - - nua_stack_unref(nua); + nua_handle_unref(nh); + nua_stack_unref(nua); } @@ -1281,11 +1223,6 @@ void sofia_event_callback(nua_event_t event, { sofia_dispatch_event_t *de; - -#ifdef DEBUG_CONN - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "GOT EVENT %s\n", x, nua_event_name(event)); -#endif - de = su_alloc(nh->nh_home, sizeof(*de)); memset(de, 0, sizeof(*de)); nua_save_event(nua, de->event); @@ -1295,17 +1232,14 @@ void sofia_event_callback(nua_event_t event, de->profile = profile; de->nua = nua_stack_ref(nua); - if (event == nua_i_invite && !sofia_private) { if (!(sofia_private = su_alloc(nh->nh_home, sizeof(*sofia_private)))) { abort(); } memset(sofia_private, 0, sizeof(*sofia_private)); - sofia_private->is_call = 2; + sofia_private->is_call++; sofia_private->de = de; - sofia_private->nh = nua_handle_ref(nh); - sofia_private->profile = profile; nua_handle_bind(nh, sofia_private); return; } @@ -1314,12 +1248,9 @@ void sofia_event_callback(nua_event_t event, switch_core_session_t *session; if (!zstr(sofia_private->uuid)) { - if ((session = switch_core_session_force_locate(sofia_private->uuid))) { + if ((session = switch_core_session_locate(sofia_private->uuid))) { if (switch_core_session_running(session)) { -#ifdef DEBUG_CONN - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SESSION QUEUE EVENT %s\n", nua_event_name(event)); -#endif switch_core_session_queue_signal_data(session, de); } else { switch_core_session_message_t msg = { 0 }; @@ -1335,10 +1266,7 @@ void sofia_event_callback(nua_event_t event, } } -#ifdef DEBUG_CONN - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "QUEUE EVENT %s\n", nua_event_name(event)); -#endif - + sofia_queue_message(de); } @@ -1623,7 +1551,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread last_commit = switch_micro_time_now(); if (len) { - //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "TRANS:\n%s\n", sqlbuf); + //printf("TRANS:\n%s\n", sqlbuf); switch_mutex_lock(profile->ireg_mutex); sofia_glue_actually_execute_sql_trans(profile, sqlbuf, NULL); //sofia_glue_actually_execute_sql(profile, "commit;\n", NULL); @@ -1639,9 +1567,6 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread } } - - sofia_nua_handle_destroy_run(profile->nh_destroy_queue); - if (switch_micro_time_now() - last_check >= 1000000) { if (profile->watchdog_enabled) { uint32_t event_diff = 0, step_diff = 0, event_fail = 0, step_fail = 0; @@ -1987,8 +1912,6 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void sofia_presence_establish_presence(profile); } - switch_queue_create(&profile->nh_destroy_queue, SOFIA_QUEUE_SIZE, profile->pool); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Starting thread for %s\n", profile->name); profile->started = switch_epoch_time_now(NULL); @@ -2018,8 +1941,6 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void } } - sofia_nua_handle_destroy_run(profile->nh_destroy_queue); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock %s\n", profile->name); switch_thread_rwlock_wrlock(profile->rwlock); sofia_reg_unregister(profile); @@ -4426,6 +4347,7 @@ static void sofia_handle_sip_r_options(switch_core_session_t *session, int statu if (sofia_private && !zstr(sofia_private->gateway_name)) { gateway = sofia_reg_find_gateway(sofia_private->gateway_name); + sofia_private->destroy_me = 1; } if (gateway) { @@ -5145,6 +5067,10 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, goto done; } } + + if (sofia_private) { + sofia_private->destroy_me = 1; + } } if (session) { @@ -5880,6 +5806,20 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status, switch_channel_hangup(channel, cause); } + + if (ss_state == nua_callstate_terminated) { + if (tech_pvt->sofia_private) { + tech_pvt->sofia_private = NULL; + } + + tech_pvt->nh = NULL; + + if (nh) { + nua_handle_bind(nh, NULL); + nua_handle_destroy(nh); + } + } + break; } @@ -7988,6 +7928,8 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ switch_mutex_unlock(tech_pvt->profile->flag_mutex); } + nua_handle_bind(nh, NULL); + sofia_private_free(sofia_private); switch_core_session_destroy(&session); nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END()); return; diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 57d0ec20e6..2b77f82af7 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -2308,8 +2308,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session) memset(sofia_private, 0, sizeof(*sofia_private)); sofia_private->is_call++; - sofia_private->nh = nua_handle_ref(tech_pvt->nh); - sofia_private->profile = tech_pvt->profile; + tech_pvt->sofia_private = sofia_private; switch_copy_string(tech_pvt->sofia_private->uuid, switch_core_session_get_uuid(session), sizeof(tech_pvt->sofia_private->uuid)); nua_handle_bind(tech_pvt->nh, tech_pvt->sofia_private); @@ -5352,7 +5351,6 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName switch_channel_set_variable(channel, "sip_handle_full_to", switch_channel_get_variable(channel, "sip_full_to")); } else { - tech_pvt->redirected = switch_core_session_sprintf(session, "sip:%s", switch_channel_get_variable(channel, "sip_contact_uri")); switch_channel_set_variable_printf(channel, "sip_invite_route_uri", "<sip:%s@%s:%s;lr>", switch_channel_get_variable(channel, "sip_from_user"), @@ -5372,7 +5370,6 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName tech_pvt->dest_to = tech_pvt->dest; - sofia_glue_attach_private(session, h->profile, tech_pvt, NULL); switch_channel_set_name(tech_pvt->channel, switch_channel_get_variable(channel, "channel_name")); diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c index 7e75fe75bf..a85138b8f6 100644 --- a/src/mod/endpoints/mod_sofia/sofia_presence.c +++ b/src/mod/endpoints/mod_sofia/sofia_presence.c @@ -1776,6 +1776,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * TAG_IF(*expires_str, SIPTAG_EXPIRES_STR(expires_str)), SIPTAG_SUBSCRIPTION_STATE_STR(sstr), SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR(ct), SIPTAG_PAYLOAD_STR(pl), TAG_END()); + nua_handle_unref(nh); end: @@ -1790,12 +1791,8 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char * switch_safe_free(pl); switch_safe_free(to); - if (nh) { - if (kill_handle) { - nua_handle_destroy(nh); - } else { - nua_handle_unref(nh); - } + if (nh && kill_handle) { + nua_handle_destroy(nh); } return 0; @@ -1839,16 +1836,14 @@ static int sofia_presence_mwi_callback(void *pArg, int argc, char **argv, char * nua_notify(nh, SIPTAG_SUBSCRIPTION_STATE_STR("active"), SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR("application/simple-message-summary"), SIPTAG_PAYLOAD_STR(body), TAG_END()); + nua_handle_unref(nh); + switch_safe_free(id); h->total++; end: - if (nh) { - nua_handle_unref(nh); - } - if (ext_profile) { sofia_glue_release_profile(ext_profile); } @@ -1939,7 +1934,6 @@ static int broadsoft_sla_notify_callback(void *pArg, int argc, char **argv, char nua_notify(nh, SIPTAG_EXPIRES_STR("0"), SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"), SIPTAG_EVENT_STR("line-seize"), SIPTAG_CALL_INFO_STR(tmp), TAG_END()); - nua_handle_unref(nh); return 0; } @@ -1948,7 +1942,6 @@ static int broadsoft_sla_notify_callback(void *pArg, int argc, char **argv, char nua_notify(nh, TAG_IF(*expires_str, SIPTAG_EXPIRES_STR(expires_str)), SIPTAG_SUBSCRIPTION_STATE_STR(sstr), SIPTAG_EVENT_STR("call-info"), SIPTAG_CALL_INFO_STR(tmp), TAG_END()); - nua_handle_unref(nh); } diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 3f7736a1ec..88c5dd4ec6 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -54,9 +54,8 @@ static void sofia_reg_new_handle(sofia_gateway_t *gateway_ptr, int attach) NUTAG_CALLSTATE_REF(ss_state), SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END()); if (attach) { if (!gateway_ptr->sofia_private) { - if (!(gateway_ptr->sofia_private = su_alloc(gateway_ptr->nh->nh_home, sizeof(*gateway_ptr->sofia_private)))) { - abort(); - } + gateway_ptr->sofia_private = malloc(sizeof(*gateway_ptr->sofia_private)); + switch_assert(gateway_ptr->sofia_private); } memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private)); @@ -187,10 +186,9 @@ void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now) NUTAG_CALLSTATE_REF(ss_state), SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END()); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "subscribing to [%s] on gateway [%s]\n", gw_sub_ptr->event, gateway_ptr->name); + gateway_ptr->sofia_private = malloc(sizeof(*gateway_ptr->sofia_private)); + switch_assert(gateway_ptr->sofia_private); - if (!(gateway_ptr->sofia_private = su_alloc(gateway_ptr->sub_nh->nh_home, sizeof(*gateway_ptr->sofia_private)))) { - abort(); - } memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private)); gateway_ptr->sofia_private->gateway = gateway_ptr; @@ -292,6 +290,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now) if (gateway_ptr->ping && !gateway_ptr->pinging && (now >= gateway_ptr->ping && (ostate == REG_STATE_NOREG || ostate == REG_STATE_REGED)) && !gateway_ptr->deleted) { nua_handle_t *nh = nua_handle(profile->nua, NULL, NUTAG_URL(gateway_ptr->register_url), TAG_END()); + sofia_private_t *pvt; register_host = sofia_glue_get_register_host(gateway_ptr->register_proxy); @@ -302,7 +301,13 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now) switch_safe_free(register_host); - nua_handle_bind(nh, &mod_sofia_globals.destroy_private); + pvt = malloc(sizeof(*pvt)); + switch_assert(pvt); + memset(pvt, 0, sizeof(*pvt)); + pvt->destroy_nh = 1; + pvt->destroy_me = 1; + switch_copy_string(pvt->gateway_name, gateway_ptr->name, sizeof(pvt->gateway_name)); + nua_handle_bind(nh, pvt); gateway_ptr->pinging = 1; nua_options(nh, diff --git a/src/mod/endpoints/mod_sofia/sofia_sla.c b/src/mod/endpoints/mod_sofia/sofia_sla.c index bd79920d1a..3dcc455d29 100644 --- a/src/mod/endpoints/mod_sofia/sofia_sla.c +++ b/src/mod/endpoints/mod_sofia/sofia_sla.c @@ -83,6 +83,7 @@ void sofia_sla_handle_register(nua_t *nua, sofia_profile_t *profile, sip_t const sofia_destination_t *dst; char *route_uri = NULL; char port_str[25] = ""; + nua_handle_t *fnh = NULL; sofia_glue_get_addr(de->data->e_msg, network_ip, sizeof(network_ip), &network_port); @@ -93,7 +94,9 @@ void sofia_sla_handle_register(nua_t *nua, sofia_profile_t *profile, sip_t const free(sql); if (*sh.call_id) { - if (!(nh = nua_handle_by_call_id(profile->nua, sh.call_id))) { + if ((nh = nua_handle_by_call_id(profile->nua, sh.call_id))) { + fnh = nh; + } else { if ((sql = switch_mprintf("delete from sip_shared_appearance_dialogs where hostname='%q' and profile_name='%q' and contact_str='%q'", mod_sofia_globals.hostname, profile->name, contact_str))) { sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE); @@ -133,6 +136,11 @@ void sofia_sla_handle_register(nua_t *nua, sofia_profile_t *profile, sip_t const SIPTAG_EXPIRES_STR(exp_str), SIPTAG_EVENT_STR("dialog;sla;include-session-description"), SIPTAG_ACCEPT_STR("application/dialog-info+xml"), TAG_NULL()); + + if (fnh) { + nua_handle_unref(fnh); + } + sofia_glue_free_destination(dst); free(contact_str); @@ -399,6 +407,7 @@ static int sofia_sla_sub_callback(void *pArg, int argc, char **argv, char **colu if (fixup && fixup != helper->payload) { free(fixup); } + nua_handle_unref(nh); } return 0; }