From 608b9abd5a719f546b594a400f5ae8d720d6d7e1 Mon Sep 17 00:00:00 2001
From: Marc Olivier Chouinard <mochouinard@moctel.com>
Date: Sat, 26 Mar 2011 10:20:06 -0400
Subject: [PATCH] mod_callcenter: Temporary fix for some race condition with
 loopback agent.  Need to find the root cause of this problem

---
 src/mod/applications/mod_callcenter/mod_callcenter.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/mod/applications/mod_callcenter/mod_callcenter.c b/src/mod/applications/mod_callcenter/mod_callcenter.c
index b8c5eede74..6f74d3ade9 100644
--- a/src/mod/applications/mod_callcenter/mod_callcenter.c
+++ b/src/mod/applications/mod_callcenter/mod_callcenter.c
@@ -1449,8 +1449,10 @@ static void *SWITCH_THREAD_FUNC outbound_agent_thread_run(switch_thread_t *threa
 
 		/* Loopback special case */
 		if (other_loopback_leg_uuid) {
-			switch_core_session_t *other_loopback_session = switch_core_session_locate(other_loopback_leg_uuid);
-			if (other_loopback_session) {
+			switch_core_session_t *other_loopback_session = NULL;
+
+			switch_yield(20000); // Wait 20ms for the channel to be ready
+			if ((other_loopback_session = switch_core_session_locate(other_loopback_leg_uuid))) {
 				switch_channel_t *other_loopback_channel = switch_core_session_get_channel(other_loopback_session);
 				const char *real_uuid = switch_channel_get_variable(other_loopback_channel, SWITCH_SIGNAL_BOND_VARIABLE);