From 53116495d17911a639e6b1d852e6d19e4d712b54 Mon Sep 17 00:00:00 2001 From: Ken Rice Date: Tue, 11 Jul 2017 17:25:48 -0500 Subject: [PATCH] Revert "FS-10416: [mod_commands] add new outbound channels to an in-progress originate" This commit causes a segfault when parsing destinations that are | delimited. This patchset needs to be tested further before inclusion into the tree. This reverts commit b11955db0bfdcccd5ad98fd689870153d31154f3. --- src/include/switch_types.h | 1 - .../applications/mod_commands/mod_commands.c | 28 +------------ src/switch_core_session.c | 1 - src/switch_ivr_originate.c | 41 +++---------------- 4 files changed, 7 insertions(+), 64 deletions(-) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index b03f7cda84..c5cd77584f 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -1548,7 +1548,6 @@ typedef enum { CF_AWAITING_STREAM_CHANGE, CF_PROCESSING_STREAM_CHANGE, CF_STREAM_CHANGED, - CF_ADD_ENDPOINTS, /* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */ /* IF YOU ADD NEW ONES CHECK IF THEY SHOULD PERSIST OR ZERO THEM IN switch_core_session.c switch_core_session_request_xml() */ CF_FLAG_MAX diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index cab1d1514d..e592b3fabc 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -4832,7 +4832,7 @@ SWITCH_STANDARD_API(pause_function) return SWITCH_STATUS_SUCCESS; } -#define ORIGINATE_SYNTAX " |&() [] [] [] [] [] []" +#define ORIGINATE_SYNTAX " |&() [] [] [] [] []" SWITCH_STANDARD_API(originate_function) { switch_channel_t *caller_channel; @@ -4858,7 +4858,7 @@ SWITCH_STANDARD_API(originate_function) switch_assert(mycmd); argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); - if (argc < 2 || argc > 8) { + if (argc < 2 || argc > 7) { stream->write_function(stream, "-USAGE: %s\n", ORIGINATE_SYNTAX); goto done; } @@ -4888,30 +4888,6 @@ SWITCH_STANDARD_API(originate_function) timeout = atoi(argv[6]); } - /* It is OK to use the caller_session and caller_channel variables instead of adding new ones, since this isn't a real originate */ - if (argv[7]) { - caller_session = switch_core_session_locate(argv[7]); - if (caller_session) { - caller_channel = switch_core_session_get_channel(caller_session); - if (caller_channel) { - if (switch_channel_test_flag(caller_channel, CF_ORIGINATOR) && switch_channel_test_flag(caller_channel, CF_ADD_ENDPOINTS) && - !switch_channel_get_variable(caller_channel, "originate_add_endpoints")) { - switch_channel_set_variable(caller_channel, "originate_add_endpoints", aleg); - stream->write_function(stream, "+OK %s\n", switch_core_session_get_uuid(caller_session)); - } else { - stream->write_function(stream, "-ERR originator is in the wrong state (originator: %d, add endpoints: %d, var: %s)\n", - switch_channel_test_flag(caller_channel, CF_ORIGINATOR), - switch_channel_test_flag(caller_channel, CF_ADD_ENDPOINTS), - switch_channel_get_variable(caller_channel, "originate_add_endpoints")); - } - } - switch_core_session_rwunlock(caller_session); - } else { - stream->write_function(stream, "-ERR originator session not found\n"); - } - goto done; - } - if (switch_ivr_originate(NULL, &caller_session, &cause, aleg, timeout, NULL, cid_name, cid_num, NULL, NULL, SOF_NONE, NULL) != SWITCH_STATUS_SUCCESS || !caller_session) { stream->write_function(stream, "-ERR %s\n", switch_channel_cause2str(cause)); diff --git a/src/switch_core_session.c b/src/switch_core_session.c index 30052ca2b7..b57e239f92 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -2154,7 +2154,6 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_xml(switch_e flags[CF_SIMPLIFY] = 0; flags[CF_VIDEO_READY] = 0; flags[CF_VIDEO_DECODED_READ] = 0; - flags[CF_ADD_ENDPOINTS] = 0; if (!(session = switch_core_session_request_uuid(endpoint_interface, direction, SOF_NO_LIMITS, pool, uuid))) { return NULL; diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index bcfa7ee18d..a8b9ddfb44 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -1929,7 +1929,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess originate_status_t originate_status[MAX_PEERS] = { {0} }; switch_originate_flag_t dftflags = SOF_NONE, myflags = dftflags; char *pipe_names[MAX_PEERS] = { 0 }; - const char *newep = NULL; char *data = NULL; switch_status_t status = SWITCH_STATUS_SUCCESS; switch_channel_t *caller_channel = NULL; @@ -1942,7 +1941,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess time_t start, global_start; switch_time_t last_retry_start = 0; switch_frame_t *read_frame = NULL; - int r = 0, i, and_argc = 0, or_argc = 0, and_argc_offset = 0; + int r = 0, i, and_argc = 0, or_argc = 0; int32_t sleep_ms = 1000, try = 0, retries = 1, retry_timelimit_sec = 0; int32_t min_retry_period_ms = sleep_ms; switch_codec_t write_codec = { 0 }; @@ -2614,7 +2613,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess last_retry_start = switch_micro_time_now(); } - add_endpoints: p = pipe_names[r]; while (p && *p) { @@ -2648,20 +2646,20 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess p++; } - and_argc += switch_separate_string(pipe_names[r], ',', peer_names, (sizeof(peer_names) / sizeof(peer_names[0]))); + and_argc = switch_separate_string(pipe_names[r], ',', peer_names, (sizeof(peer_names) / sizeof(peer_names[0]))); if ((flags & SOF_NOBLOCK) && and_argc > 1) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Only calling the first element in the list in this mode.\n"); and_argc = 1; } - for (i = and_argc_offset; i < and_argc; i++) { + for (i = 0; i < and_argc; i++) { const char *current_variable; switch_event_t *local_var_event = NULL, *originate_var_event = NULL; end = NULL; - chan_type = peer_names[i-and_argc_offset]; + chan_type = peer_names[i]; /* strip leading spaces */ @@ -3057,7 +3055,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess for (;;) { uint32_t valid_channels = 0; - for (i = and_argc_offset; i < and_argc; i++) { + for (i = 0; i < and_argc; i++) { int state; time_t elapsed; @@ -3137,7 +3135,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess if (caller_channel) { soft_holding = switch_channel_get_variable(caller_channel, SWITCH_SOFT_HOLDING_UUID_VARIABLE); - switch_channel_set_flag(caller_channel, CF_ADD_ENDPOINTS); } while ((!caller_channel || switch_channel_ready(caller_channel) || switch_channel_test_flag(caller_channel, CF_XFER_ZOMBIE)) && @@ -3282,8 +3279,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess break; case SWITCH_STATUS_BREAK: status = SWITCH_STATUS_FALSE; - switch_channel_clear_flag(caller_channel, CF_ADD_ENDPOINTS); - switch_channel_set_variable(caller_channel, "originate_add_endpoints", NULL); goto done; break; default: @@ -3387,17 +3382,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess do_continue: - if(caller_channel) { - newep = switch_channel_get_variable(caller_channel, "originate_add_endpoints"); - if (newep) { - switch_channel_set_variable(caller_channel, "originate_add_endpoints", NULL); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Add new originate endpoint(s): %s\n", newep); - and_argc_offset = and_argc; - pipe_names[r] = strdup(newep); - goto add_endpoints; - } - } - if (!read_packet) { switch_yield(20000); } @@ -3406,21 +3390,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess notready: if (caller_channel) { - - switch_channel_clear_flag(caller_channel, CF_ADD_ENDPOINTS); - newep = switch_channel_get_variable(caller_channel, "originate_add_endpoints"); - if (newep) { - switch_channel_set_variable(caller_channel, "originate_add_endpoints", NULL); - - /* Only add new endpoints at this stage, if it's not originator cancel and if no outbound leg was aswered */ - if(oglobals.idx != IDX_CANCEL && oglobals.hups == and_argc) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Add new originate endpoints: %s\n", newep); - and_argc_offset = and_argc; - pipe_names[r] = strdup(newep); - goto add_endpoints; - } - } - holding = switch_channel_get_variable(caller_channel, SWITCH_HOLDING_UUID_VARIABLE); switch_channel_set_variable(caller_channel, SWITCH_HOLDING_UUID_VARIABLE, NULL);