]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-6310 --resolve try this version
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 31 Mar 2014 22:02:55 +0000 (17:02 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 31 Mar 2014 22:03:21 +0000 (17:03 -0500)
src/switch_ivr_bridge.c

index 92b03e1086c3c225be358bee26a8d1e9b8e8abd0..3e7dde4d077aa2f2a56fea5f49ed0f5d580a93d5 100644 (file)
@@ -190,6 +190,7 @@ struct switch_ivr_bridge_data {
        switch_input_callback_function_t input_callback;
        void *session_data;
        int clean_exit;
+       int state_done;
        int done;
        struct switch_ivr_bridge_data *other_leg_data;
 };
@@ -218,6 +219,7 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
        time_t answer_limit = 0;
        const char *exec_app = NULL;
        const char *exec_data = NULL;
+       int sanity = 500;
 
 #ifdef SWITCH_VIDEO_IN_THREADS
        switch_thread_t *vid_thread = NULL;
@@ -645,6 +647,10 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session_a), SWITCH_LOG_DEBUG, "BRIDGE THREAD DONE [%s]\n", switch_channel_get_name(chan_a));
        switch_channel_clear_flag(chan_a, CF_BRIDGED);
        
+       while(--sanity > 0 && !data->other_leg_data->state_done) {
+               switch_yield(10000);
+       }
+
        if (switch_channel_test_flag(chan_a, CF_LEG_HOLDING) || switch_channel_test_flag(chan_a, CF_HANGUP_HELD)) {
                if (switch_channel_ready(chan_b) && switch_channel_get_state(chan_b) != CS_PARK && !data->other_leg_data->clean_exit) {
                        const char *ext = switch_channel_get_variable(chan_a, "hold_hangup_xfer_exten");
@@ -728,6 +734,8 @@ static switch_status_t audio_bridge_on_exchange_media(switch_core_session_t *ses
                        if (switch_channel_test_flag(channel, CF_INTERCEPTED)) {
                                switch_channel_clear_flag(channel, CF_INTERCEPT);
                                switch_channel_clear_flag(channel, CF_INTERCEPTED);
+                               bd->clean_exit = 1;
+                               bd->state_done = 1;
                                return SWITCH_STATUS_FALSE;
                        } else {
                                if (switch_channel_test_flag(channel, CF_INTERCEPT)) {
@@ -743,11 +751,15 @@ static switch_status_t audio_bridge_on_exchange_media(switch_core_session_t *ses
                }
        }
 
+       bd->clean_exit = 1;
+
        if (switch_channel_get_state(channel) == CS_EXCHANGE_MEDIA) {
                switch_channel_set_variable(channel, "park_timeout", "3");
                switch_channel_set_state(channel, CS_PARK);
        }
 
+       bd->state_done = 1;
+
        return SWITCH_STATUS_FALSE;
 }
 
@@ -1451,6 +1463,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
 
                        switch_channel_stop_broadcast(peer_channel);
 
+                       a_leg->state_done = 1;
 
                        while (switch_channel_get_state(peer_channel) == CS_EXCHANGE_MEDIA) {
                                switch_ivr_parse_all_messages(session);