switch_channel_get_state(_peer) == CS_RESET || \
!switch_channel_test_flag(_peer, CF_ORIGINATING)))
+static void wait_for_cause(switch_channel_t *channel)
+{
+ int sanity = 5;
+
+ while (--sanity > 0 && peer_eligible(channel) && switch_channel_get_cause(channel) == SWITCH_CAUSE_NONE) {
+ switch_yield(10000);
+ }
+}
+
+
SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *session,
switch_core_session_t **bleg,
if (i != oglobals.idx) {
holding = NULL;
-
+
if (oglobals.idx == IDX_TIMEOUT || to) {
reason = SWITCH_CAUSE_NO_ANSWER;
} else {
} else {
if (and_argc > 1) {
reason = SWITCH_CAUSE_LOSE_RACE;
+ } else if (!switch_channel_ready(originate_status[i].peer_channel)) {
+ wait_for_cause(originate_status[i].peer_channel);
+ if (switch_channel_down(originate_status[i].peer_channel)) {
+ reason = switch_channel_get_cause(originate_status[i].peer_channel);
+ }
} else {
reason = SWITCH_CAUSE_NO_ANSWER;
}
}
if (peer_channel) {
+ wait_for_cause(peer_channel);
*cause = switch_channel_get_cause(peer_channel);
} else {
for (i = 0; i < and_argc; i++) {
*cause = switch_channel_get_cause(caller_channel);
} else {
*cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
+ for (i = 0; i < and_argc; i++) {
+ if (!peer_eligible(originate_status[i].peer_channel)) {
+ continue;
+ }
+
+ wait_for_cause(originate_status[i].peer_channel);
+
+ if (switch_channel_down(originate_status[i].peer_channel)) {
+ *cause = switch_channel_get_cause(originate_status[i].peer_channel);
+ break;
+ }
+
+ }
}
}
continue;
}
pchannel = switch_core_session_get_channel(originate_status[i].peer_session);
-
+ wait_for_cause(pchannel);
if (switch_channel_down(pchannel)) {
cause_str = switch_channel_cause2str(switch_channel_get_cause(pchannel));
if (switch_stristr(cause_str, fail_on_single_reject_var)) {