]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
omfg
authorAnthony Minessale <anthony.minessale@gmail.com>
Sat, 23 Jan 2010 06:53:30 +0000 (06:53 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Sat, 23 Jan 2010 06:53:30 +0000 (06:53 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16477 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_core_session.c
src/switch_ivr.c
src/switch_ivr_bridge.c

index d8a454290cb2eead915b3fe0fb0e5bad7a956b5f..0bf16bb69c056af68bf11867353a2b21646d7e08 100644 (file)
@@ -985,10 +985,16 @@ SWITCH_DECLARE(switch_channel_t *) switch_core_session_get_channel(switch_core_s
 
 SWITCH_DECLARE(void) switch_core_session_wake_session_thread(switch_core_session_t *session)
 {
+       int x = 5;
        /* If trylock fails the signal is already awake so we needn't bother */
-       if (switch_mutex_trylock(session->mutex) == SWITCH_STATUS_SUCCESS) {
-               switch_thread_cond_signal(session->cond);
-               switch_mutex_unlock(session->mutex);
+       for(;;) {
+               if (switch_mutex_trylock(session->mutex) == SWITCH_STATUS_SUCCESS) {
+                       switch_thread_cond_signal(session->cond);
+                       switch_mutex_unlock(session->mutex);
+                       return;
+               }
+               if (!--x) return;
+               switch_yield(1000);
        }
 }
 
index c87c0acbdfde1c23abbf218bb69bfc5e108caa44..498913eb220f859f6122e4931f7c3dcdd7d9ae4b 100644 (file)
@@ -1216,6 +1216,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_media(const char *uuid, switch_media_
                                switch_assert(other_channel != NULL);
                                switch_core_session_receive_message(other_session, &msg);
                                switch_channel_wait_for_flag(other_channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
+                               switch_channel_wait_for_flag(other_channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
+                               switch_channel_wait_for_flag(other_channel, CF_MEDIA_SET, SWITCH_TRUE, 10000, NULL);
                                switch_core_session_read_frame(other_session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
                                switch_channel_clear_state_handler(other_channel, NULL);
                                switch_core_session_rwunlock(other_session);
@@ -1262,25 +1264,43 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_nomedia(const char *uuid, switch_medi
                }
 
                if ((flags & SMF_FORCE) || !switch_channel_test_flag(channel, CF_PROXY_MODE)) {
+                       switch_channel_set_flag(channel, CF_REDIRECT);
+                       switch_channel_set_state(channel, CS_PARK);
+                       switch_channel_set_flag(channel, CF_TRANSFER);
+
                        switch_core_session_receive_message(session, &msg);
 
                        if ((flags & SMF_REBRIDGE) && (other_uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) &&
                                (other_session = switch_core_session_locate(other_uuid))) {
                                other_channel = switch_core_session_get_channel(other_session);
 
+                               switch_channel_set_flag(other_channel, CF_REDIRECT);
+                               switch_channel_set_state(other_channel, CS_PARK);
+                               switch_channel_set_flag(other_channel, CF_TRANSFER);
+                               
+                               
                                switch_core_session_receive_message(other_session, &msg);
                                switch_channel_clear_state_handler(other_channel, NULL);
                        }
 
                        if (other_channel) {
+                               switch_channel_wait_for_state(other_channel, channel, CS_PARK);
+                       }
+                       switch_channel_wait_for_state_timeout(channel, CS_PARK, 5000000);
+                       
+                       switch_channel_clear_flag(channel, CF_NOT_READY);
+
+                       if (other_channel) {
+                               switch_channel_clear_flag(other_channel, CF_NOT_READY);
+                               
                                switch_channel_clear_state_handler(channel, NULL);
                                if (swap) {
                                        switch_ivr_signal_bridge(other_session, session);
                                } else {
                                        switch_ivr_signal_bridge(session, other_session);
                                }
-                               switch_channel_wait_for_flag(channel, CF_BRIDGED, SWITCH_TRUE, 1000, NULL);
-                               switch_channel_wait_for_flag(other_channel, CF_BRIDGED, SWITCH_TRUE, 1000, NULL);
+                               switch_channel_wait_for_state(other_channel, channel, CS_HIBERNATE);
+                               switch_channel_wait_for_state(channel, other_channel, CS_HIBERNATE);
                                switch_core_session_rwunlock(other_session);
                        }
                }
index 10cb8193c77a1db5ee9c531d4f90010b25cb235d..6b61e6868d2d0320db9834a44ff3c8eccee92f0f 100644 (file)
@@ -891,7 +891,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_signal_bridge(switch_core_session_t *
                return SWITCH_STATUS_FALSE;
        }
 
-       if (!switch_channel_ready(caller_channel)) {
+       if (!switch_channel_up(caller_channel)) {
                switch_channel_hangup(peer_channel, SWITCH_CAUSE_ORIGINATOR_CANCEL);
                return SWITCH_STATUS_FALSE;
        }
@@ -1192,9 +1192,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
     }
 
        if (switch_channel_test_flag(caller_channel, CF_REDIRECT)) {
-               state = switch_channel_get_state(caller_channel);
-               if (!(state == CS_RESET || state == CS_PARK || state == CS_ROUTING)) {
-                       switch_channel_set_state(caller_channel, CS_RESET);
+               if (switch_channel_test_flag(caller_channel, CF_RESET)) {
+                       switch_channel_clear_flag(caller_channel, CF_RESET);
+               } else {
+                       state = switch_channel_get_state(caller_channel);
+                       if (!(state == CS_RESET || state == CS_PARK || state == CS_ROUTING)) {
+                               switch_channel_set_state(caller_channel, CS_RESET);
+                       }
                }
        }