Revision
16480
Author
brian
Date
2010-01-23 12:35:05 -0600 (Sat, 23 Jan 2010)

Log Message

 fix some bypass media scenarios 

Modified Paths

Diff

Modified: freeswitch/trunk/src/include/switch_core.h (16479 => 16480)


--- freeswitch/trunk/src/include/switch_core.h	2010-01-23 16:16:54 UTC (rev 16479)
+++ freeswitch/trunk/src/include/switch_core.h	2010-01-23 18:35:05 UTC (rev 16480)
@@ -2071,6 +2071,7 @@
 SWITCH_DECLARE(uint32_t) switch_core_debug_level(void);
 SWITCH_DECLARE(void) switch_cache_db_flush_handles(void);
 SWITCH_DECLARE(const char *) switch_core_banner(void);
+SWITCH_DECLARE(switch_bool_t) switch_core_session_in_thread(switch_core_session_t *session);
 
 SWITCH_END_EXTERN_C
 #endif

Modified: freeswitch/trunk/src/switch_core_session.c (16479 => 16480)


--- freeswitch/trunk/src/switch_core_session.c	2010-01-23 16:16:54 UTC (rev 16479)
+++ freeswitch/trunk/src/switch_core_session.c	2010-01-23 18:35:05 UTC (rev 16480)
@@ -1141,6 +1141,14 @@
 	
 }
 
+SWITCH_DECLARE(switch_bool_t) switch_core_session_in_thread(switch_core_session_t *session)
+{
+	if (switch_thread_self() == session->thread_id) {
+		return SWITCH_TRUE;
+	}
+	return SWITCH_FALSE;
+}
+
 static void *SWITCH_THREAD_FUNC switch_core_session_thread(switch_thread_t *thread, void *obj)
 {
 	switch_core_session_t *session = obj;

Modified: freeswitch/trunk/src/switch_ivr.c (16479 => 16480)


--- freeswitch/trunk/src/switch_ivr.c	2010-01-23 16:16:54 UTC (rev 16479)
+++ freeswitch/trunk/src/switch_ivr.c	2010-01-23 18:35:05 UTC (rev 16480)
@@ -1286,7 +1286,9 @@
 			if (other_channel) {
 				switch_channel_wait_for_state(other_channel, channel, CS_PARK);
 			}
-			switch_channel_wait_for_state_timeout(channel, CS_PARK, 5000000);
+			if (switch_core_session_in_thread(session)) {
+				switch_yield(100000);
+			}
 			
 			switch_channel_clear_flag(channel, CF_NOT_READY);
 
@@ -1300,7 +1302,9 @@
 					switch_ivr_signal_bridge(session, other_session);
 				}
 				switch_channel_wait_for_state(other_channel, channel, CS_HIBERNATE);
-				switch_channel_wait_for_state(channel, other_channel, CS_HIBERNATE);
+				if (switch_core_session_in_thread(session)) {
+					switch_yield(100000);
+				}
 				switch_core_session_rwunlock(other_session);
 			}
 		}

Modified: freeswitch/trunk/src/switch_ivr_bridge.c (16479 => 16480)


--- freeswitch/trunk/src/switch_ivr_bridge.c	2010-01-23 16:16:54 UTC (rev 16479)
+++ freeswitch/trunk/src/switch_ivr_bridge.c	2010-01-23 18:35:05 UTC (rev 16480)
@@ -30,7 +30,7 @@
  */
 
 #include <switch.h>
-#define DEFAULT_LEAD_FRAMES 5
+#define DEFAULT_LEAD_FRAMES 10
 
 static const switch_state_handler_table_t audio_bridge_peer_state_handlers;
 static void cleanup_proxy_mode_a(switch_core_session_t *session);
@@ -839,18 +839,22 @@
             switch_channel_set_variable(other_channel, SWITCH_BRIDGE_VARIABLE, NULL);
 			
             if (switch_channel_up(other_channel)) {
+
 				if (switch_true(switch_channel_get_variable(other_channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE))) {
 					switch_ivr_park_session(other_session);
 				} else if ((var = switch_channel_get_variable(other_channel, SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE))) {
 					transfer_after_bridge(other_session, var);
 				}
-				
-				if (switch_channel_test_flag(other_channel, CF_BRIDGE_ORIGINATOR) && 
-					switch_channel_test_flag(channel, CF_ANSWERED) &&
-					switch_true(switch_channel_get_variable(other_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE))) {
-					switch_channel_hangup(other_channel, switch_channel_get_cause(channel));	
+
+				if (switch_channel_test_flag(other_channel, CF_BRIDGE_ORIGINATOR)) {
+					if (switch_channel_test_flag(channel, CF_ANSWERED) &&
+						switch_true(switch_channel_get_variable(other_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE))) {
+						switch_channel_hangup(other_channel, switch_channel_get_cause(channel));	
+					} else {
+						switch_channel_set_state(other_channel, CS_EXECUTE);
+					}
 				} else {
-					switch_channel_set_state(other_channel, CS_EXECUTE);
+					switch_channel_hangup(other_channel, switch_channel_get_cause(channel));
 				}
             }
         }