1
0
mirror of https://github.com/signalwire/freeswitch.git synced 2025-04-18 17:41:53 +00:00

fix fail_on_single_reject

This commit is contained in:
Anthony Minessale 2010-10-25 13:03:06 -05:00
parent 59d3b84def
commit cd736a1c77

@ -1735,6 +1735,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
const char *soft_holding = NULL;
early_state_t early_state = { 0 };
int read_packet = 0;
int check_reject = 1;
if (strstr(bridgeto, SWITCH_ENT_ORIGINATE_DELIM)) {
return switch_ivr_enterprise_originate(session, bleg, cause, bridgeto, timelimit_sec, table, cid_name_override, cid_num_override,
@ -2081,9 +2082,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
If the value is set to 'true' any fail cause will end the attempt otherwise it can contain a comma (,) separated
list of cause names which should be considered fatal
*/
if ((var = switch_event_get_header(var_event, "fail_on_single_reject")) && switch_true(var)) {
if ((var = switch_event_get_header(var_event, "fail_on_single_reject"))) {
fail_on_single_reject_var = strdup(var);
fail_on_single_reject = 1;
if (switch_true(var)) {
fail_on_single_reject = 1;
} else {
fail_on_single_reject = -1;
}
}
if ((*oglobals.file != '\0') && (!strcmp(oglobals.file, "undef"))) {
@ -2232,6 +2237,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
char *p, *end = NULL;
const char *var_begin, *var_end;
int q = 0;
check_reject = 1;
oglobals.hups = 0;
reason = SWITCH_CAUSE_NONE;
@ -2605,6 +2612,15 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot create outgoing channel of type [%s] cause: [%s]\n",
chan_type, switch_channel_cause2str(reason));
if (local_var_event) switch_event_destroy(&local_var_event);
if (fail_on_single_reject_var) {
const char *cause_str = switch_channel_cause2str(reason);
check_reject = 0;
if (fail_on_single_reject == 1 || switch_stristr(cause_str, fail_on_single_reject_var)) {
goto outer_for;
}
}
continue;
}
@ -2848,26 +2864,29 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
}
goto notready;
}
if ((to = (uint8_t) (elapsed >= (time_t) timelimit_sec)) || (fail_on_single_reject && oglobals.hups)) {
int ok = 0;
if (fail_on_single_reject_var && !switch_true(fail_on_single_reject_var)) {
ok = 1;
for (i = 0; i < and_argc; i++) {
switch_channel_t *pchannel;
const char *cause_str;
if (fail_on_single_reject_var) {
if (!switch_true(fail_on_single_reject_var)) {
ok = 1;
if (!originate_status[i].peer_session) {
goto do_continue;
}
pchannel = switch_core_session_get_channel(originate_status[i].peer_session);
for (i = 0; i < and_argc; i++) {
switch_channel_t *pchannel;
const char *cause_str;
if (!originate_status[i].peer_session) {
continue;
}
pchannel = switch_core_session_get_channel(originate_status[i].peer_session);
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)) {
ok = 0;
break;
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)) {
ok = 0;
break;
}
}
}
}
@ -3476,26 +3495,31 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
} else {
int ok = 0;
if (fail_on_single_reject_var && !switch_true(fail_on_single_reject_var)) {
ok = 1;
for (i = 0; i < and_argc; i++) {
switch_channel_t *pchannel;
const char *cause_str;
if (fail_on_single_reject && check_reject) {
if (!originate_status[i].peer_session) {
continue;
}
pchannel = switch_core_session_get_channel(originate_status[i].peer_session);
if (!switch_true(fail_on_single_reject_var)) {
ok = 1;
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)) {
ok = 0;
break;
for (i = 0; i < and_argc; i++) {
switch_channel_t *pchannel;
const char *cause_str;
if (!originate_status[i].peer_session) {
continue;
}
pchannel = switch_core_session_get_channel(originate_status[i].peer_session);
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)) {
ok = 0;
break;
}
}
}
}
}
if (ok) {
goto outer_for;
}