]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
format refactor
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 17 Jun 2010 19:28:31 +0000 (14:28 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 17 Jun 2010 19:36:31 +0000 (14:36 -0500)
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/sofia_glue.c
src/switch_core_session.c

index fe10dfce1ca31863753b3ee7d752956234f289bb..aa8516b016faaa4d99afbe6323dc31dd7b4502cf 100644 (file)
@@ -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) {
index 93cf586901dc4d890f6744137e214ae0241ff5e8..83aeda2a3d22c3a5a5c04e40a453fb783f903874 100644 (file)
@@ -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++;
index 842c3c97243904d14571a105f6ce70ccb6a85ef0..ec9c988c5f815b070adfdb4b527563c95d385ab8 100644 (file)
@@ -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;
 }