summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins2 <jenkins2@gerrit.asterisk.org>2017-10-11 15:14:18 -0500
committerGerrit Code Review <gerrit2@gerrit.digium.api>2017-10-11 15:14:18 -0500
commit304403fe1173de2c1590f79f0c94aaae0b04353f (patch)
tree5499afae3f83d0313e1eedd85eb2cf3c52f56418
parent165fdf2a6672faeb74a608b56cb3d046ee636701 (diff)
parent1541e2c70acbf0ec6e60d836362b4d660adba955 (diff)
Merge "app_originate: Set ORIGINATE_STATUS correctly on failure" into 14
-rw-r--r--apps/app_originate.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/apps/app_originate.c b/apps/app_originate.c
index 88245f0a6..6093f30fd 100644
--- a/apps/app_originate.c
+++ b/apps/app_originate.c
@@ -110,6 +110,7 @@ static int originate_exec(struct ast_channel *chan, const char *data)
char *parse;
char *chantech, *chandata;
int res = -1;
+ int continue_in_dialplan = 0;
int outgoing_status = 0;
unsigned int timeout = 30;
static const char default_exten[] = "s";
@@ -159,6 +160,12 @@ static int originate_exec(struct ast_channel *chan, const char *data)
goto return_cleanup;
}
+ if (strcasecmp(args.type, "exten") && strcasecmp(args.type, "app")) {
+ ast_log(LOG_ERROR, "Incorrect type, it should be 'exten' or 'app': %s\n",
+ args.type);
+ goto return_cleanup;
+ }
+
if (!strcasecmp(args.type, "exten")) {
int priority = 1; /* Initialized in case priority not specified */
const char *exten = args.arg2;
@@ -177,23 +184,30 @@ static int originate_exec(struct ast_channel *chan, const char *data)
ast_debug(1, "Originating call to '%s/%s' and connecting them to extension %s,%s,%d\n",
chantech, chandata, args.arg1, exten, priority);
- ast_pbx_outgoing_exten(chantech, cap_slin, chandata,
+ res = ast_pbx_outgoing_exten(chantech, cap_slin, chandata,
timeout * 1000, args.arg1, exten, priority, &outgoing_status,
AST_OUTGOING_WAIT, NULL, NULL, NULL, NULL, NULL, 0, NULL);
- } else if (!strcasecmp(args.type, "app")) {
+ } else {
ast_debug(1, "Originating call to '%s/%s' and connecting them to %s(%s)\n",
chantech, chandata, args.arg1, S_OR(args.arg2, ""));
- ast_pbx_outgoing_app(chantech, cap_slin, chandata,
+ res = ast_pbx_outgoing_app(chantech, cap_slin, chandata,
timeout * 1000, args.arg1, args.arg2, &outgoing_status,
AST_OUTGOING_WAIT, NULL, NULL, NULL, NULL, NULL, NULL);
- } else {
- ast_log(LOG_ERROR, "Incorrect type, it should be 'exten' or 'app': %s\n",
- args.type);
- goto return_cleanup;
}
- res = 0;
+ /*
+ * Getting here means that we have passed the various validation checks and
+ * have at least attempted the dial. If we have a reason (outgoing_status),
+ * we clear our error indicator so that we ultimately report the right thing
+ * to the caller.
+ */
+ if (res && outgoing_status) {
+ res = 0;
+ }
+
+ /* We need to exit cleanly if we've gotten this far */
+ continue_in_dialplan = 1;
return_cleanup:
if (res) {
@@ -226,7 +240,7 @@ return_cleanup:
ao2_cleanup(cap_slin);
ast_autoservice_stop(chan);
- return res;
+ return continue_in_dialplan ? 0 : -1;
}
static int unload_module(void)