]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Revert "FS-10416: [mod_commands] add new outbound channels to an in-progress originate"
authorKen Rice <krice@freeswitch.org>
Tue, 11 Jul 2017 22:25:48 +0000 (17:25 -0500)
committerKen Rice <krice@freeswitch.org>
Tue, 11 Jul 2017 22:25:48 +0000 (17:25 -0500)
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
src/mod/applications/mod_commands/mod_commands.c
src/switch_core_session.c
src/switch_ivr_originate.c

index b03f7cda84985ce17890c5406e3b3688dee9c16d..c5cd77584f7fde6c085561a5925b38d8e46acfa2 100644 (file)
@@ -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
index cab1d1514df66b093d000411cb3df80e78e2fac0..e592b3fabcd5c68e6cd87416732e86145d8adb36 100644 (file)
@@ -4832,7 +4832,7 @@ SWITCH_STANDARD_API(pause_function)
        return SWITCH_STATUS_SUCCESS;
 }
 
-#define ORIGINATE_SYNTAX "<call url> <exten>|&<application_name>(<app_args>) [<dialplan>] [<context>] [<cid_name>] [<cid_num>] [<timeout_sec>] [<originator_uuid>]"
+#define ORIGINATE_SYNTAX "<call url> <exten>|&<application_name>(<app_args>) [<dialplan>] [<context>] [<cid_name>] [<cid_num>] [<timeout_sec>]"
 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));
index 30052ca2b711dba4cffcc499d3129c7bd0fd2e79..b57e239f92cb57127328a1f53e722b15792b5f57 100644 (file)
@@ -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;
index bcfa7ee18dbe38cb44b14b1b3097b3730b42eec0..a8b9ddfb44ed55e49bb522c710eba191fcf8ce2d 100644 (file)
@@ -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);