From 8b4a8cc3efed0596576b04590ed11a979288beb5 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 17 Jun 2010 14:28:31 -0500 Subject: [PATCH] format refactor --- src/mod/endpoints/mod_sofia/mod_sofia.c | 6 +++++- src/mod/endpoints/mod_sofia/sofia_glue.c | 18 +++++++++++++----- src/switch_core_session.c | 6 ++++++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index fe10dfce1c..aa8516b016 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -394,6 +394,7 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session) const char *ps_cause = NULL, *use_my_cause; const char *gateway_name = NULL; sofia_gateway_t *gateway_ptr = NULL; + int rec; if ((gateway_name = switch_channel_get_variable(channel, "sip_gateway_name"))) { gateway_ptr = sofia_reg_find_gateway(gateway_name); @@ -401,9 +402,12 @@ switch_status_t sofia_on_hangup(switch_core_session_t *session) switch_mutex_lock(tech_pvt->sofia_mutex); + rec = sofia_test_flag(tech_pvt, TFLAG_RECOVERING); sofia_clear_flag(tech_pvt, TFLAG_RECOVERING); - sofia_glue_tech_untrack(tech_pvt->profile, session, SWITCH_TRUE); + if (!rec) { + sofia_glue_tech_untrack(tech_pvt->profile, session, SWITCH_TRUE); + } if (!switch_channel_test_flag(channel, CF_ANSWERED)) { if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 93cf586901..83aeda2a3d 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -4454,6 +4454,8 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName const char *r_ip = switch_channel_get_variable(channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE); const char *r_port = switch_channel_get_variable(channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE); + sofia_set_flag(tech_pvt, TFLAG_RECOVERING); + if (!switch_channel_test_flag(channel, CF_PROXY_MODE) && ip && port) { const char *tmp; tech_pvt->iananame = tech_pvt->rm_encoding = (char *) switch_channel_get_variable(channel, "sip_use_codec_name"); @@ -4475,7 +4477,11 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName tech_pvt->adv_sdp_audio_ip = tech_pvt->extrtpip = (char *) ip; tech_pvt->adv_sdp_audio_port = tech_pvt->local_sdp_audio_port = atoi(port); - tech_pvt->local_sdp_audio_ip = tech_pvt->rtpip; + + if ((tmp = switch_channel_get_variable(channel, "local_media_ip"))) { + tech_pvt->local_sdp_audio_ip = switch_core_session_strdup(session, tmp); + tech_pvt->rtpip = tech_pvt->local_sdp_audio_ip; + } if (r_ip && r_port) { tech_pvt->remote_sdp_audio_ip = (char *) r_ip; @@ -4518,11 +4524,12 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 1); - sofia_glue_activate_rtp(tech_pvt, 0); + if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) { + switch_xml_free(xml); + return 0; + } } - - sofia_set_flag(tech_pvt, TFLAG_RECOVERING); - + if (switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) { sofia_set_flag(tech_pvt, TFLAG_RECOVERING_BRIDGE); } else { @@ -4548,6 +4555,7 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Resurrecting fallen channel %s\n", switch_channel_get_name(channel)); switch_core_session_thread_launch(session); + switch_xml_free(xml); h->total++; diff --git a/src/switch_core_session.c b/src/switch_core_session.c index 842c3c9724..ec9c988c5f 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -1201,6 +1201,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_thread_launch(switch_core_se switch_threadattr_create(&thd_attr, session->pool); switch_threadattr_detach_set(thd_attr, 1); + if (switch_test_flag(session, SSF_THREAD_RUNNING) || switch_test_flag(session, SSF_THREAD_STARTED)) { + goto end; + } + switch_mutex_lock(session->mutex); if (switch_test_flag(session, SSF_THREAD_RUNNING)) { @@ -1223,6 +1227,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_thread_launch(switch_core_se switch_mutex_unlock(session->mutex); + end: + return status; }