[Asterisk-code-review] manager: Restore Originate failure behavior from Asterisk 11 (asterisk[13])

Sean Bright asteriskteam at digium.com
Thu Feb 9 10:20:23 CST 2017


Sean Bright has uploaded a new change for review. ( https://gerrit.asterisk.org/4913 )

Change subject: manager: Restore Originate failure behavior from Asterisk 11
......................................................................

manager: Restore Originate failure behavior from Asterisk 11

In Asterisk 11, if the 'Originate' AMI command failed to connect the provided
Channel while in extension mode, a 'failed' extension would be looked up and
run. This was, I believe, unintentionally removed in 51b6c49. This patch
restores that behavior.

This also adds preprocessor defintions for the various 'synchronous' modes in
an attempt to make them meaningful.

ASTERISK-26115 #close
Reported by: Nasir Iqbal

Change-Id: I8afbd06725e99610e02adb529137d4800c05345d
---
M apps/app_originate.c
M funcs/func_periodic_hook.c
M include/asterisk/pbx.h
M main/manager.c
M pbx/pbx_spool.c
M res/res_clioriginate.c
6 files changed, 37 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/13/4913/1

diff --git a/apps/app_originate.c b/apps/app_originate.c
index 15898b2..2496a0c 100644
--- a/apps/app_originate.c
+++ b/apps/app_originate.c
@@ -178,15 +178,15 @@
 				chantech, chandata, args.arg1, exten, priority);
 
 		ast_pbx_outgoing_exten(chantech, cap_slin, chandata,
-				timeout * 1000, args.arg1, exten, priority, &outgoing_status, 1, NULL,
-				NULL, NULL, NULL, NULL, 0, NULL);
+				timeout * 1000, args.arg1, exten, priority, &outgoing_status,
+				AST_OUTGOING_EXT_WAIT, NULL, NULL, NULL, NULL, NULL, 0, NULL);
 	} else if (!strcasecmp(args.type, "app")) {
 		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,
-				timeout * 1000, args.arg1, args.arg2, &outgoing_status, 1, NULL,
-				NULL, NULL, NULL, NULL, NULL);
+				timeout * 1000, args.arg1, args.arg2, &outgoing_status,
+				AST_OUTGOING_APP_WAIT, NULL, NULL, NULL, NULL, NULL, NULL);
 	} else {
 		ast_log(LOG_ERROR, "Incorrect type, it should be 'exten' or 'app': %s\n",
 				args.type);
diff --git a/funcs/func_periodic_hook.c b/funcs/func_periodic_hook.c
index cb019b4..6c8c951 100644
--- a/funcs/func_periodic_hook.c
+++ b/funcs/func_periodic_hook.c
@@ -183,8 +183,8 @@
 	};
 
 	ast_pbx_outgoing_exten("Local", NULL, full_exten_name, 60,
-			arg->context, arg->exten, 1, NULL, 0, NULL, NULL, &chan_name_var,
-			NULL, NULL, 1, NULL);
+			arg->context, arg->exten, 1, NULL, AST_OUTGOING_EXT_NO_WAIT,
+			NULL, NULL, &chan_name_var, NULL, NULL, 1, NULL);
 
 	hook_thread_arg_destroy(arg);
 
diff --git a/include/asterisk/pbx.h b/include/asterisk/pbx.h
index 1fc8df8..d366399 100644
--- a/include/asterisk/pbx.h
+++ b/include/asterisk/pbx.h
@@ -1130,6 +1130,10 @@
  */
 int ast_async_goto_by_name(const char *chan, const char *context, const char *exten, int priority);
 
+#define AST_OUTGOING_EXT_NO_WAIT          0
+#define AST_OUTGOING_EXT_WAIT             1
+#define AST_OUTGOING_EXT_WAIT_GOTO_FAILED 2
+
 /*!
  * \brief Synchronously or asynchronously make an outbound call and send it to a
  * particular extension
@@ -1167,6 +1171,10 @@
 	const char *account, struct ast_channel **locked_channel, int early_media,
 	const struct ast_assigned_ids *assignedids);
 
+#define AST_OUTGOING_APP_NO_WAIT       0
+#define AST_OUTGOING_APP_WAIT          1
+#define AST_OUTGOING_APP_WAIT_COMPLETE 2
+
 /*!
  * \brief Synchronously or asynchronously make an outbound call and execute an
  *  application on the channel.
diff --git a/main/manager.c b/main/manager.c
index 251085a..1a18481 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -5096,13 +5096,15 @@
 
 	if (!ast_strlen_zero(in->app)) {
 		res = ast_pbx_outgoing_app(in->tech, in->cap, in->data,
-			in->timeout, in->app, in->appdata, &reason, 1,
+			in->timeout, in->app, in->appdata, &reason,
+			AST_OUTGOING_APP_WAIT,
 			S_OR(in->cid_num, NULL),
 			S_OR(in->cid_name, NULL),
 			in->vars, in->account, &chan, &assignedids);
 	} else {
 		res = ast_pbx_outgoing_exten(in->tech, in->cap, in->data,
-			in->timeout, in->context, in->exten, in->priority, &reason, 1,
+			in->timeout, in->context, in->exten, in->priority, &reason,
+			AST_OUTGOING_EXT_WAIT_GOTO_FAILED,
 			S_OR(in->cid_num, NULL),
 			S_OR(in->cid_name, NULL),
 			in->vars, in->account, &chan, in->early_media, &assignedids);
@@ -5573,11 +5575,16 @@
 			}
 		}
 	} else if (!ast_strlen_zero(app)) {
-		res = ast_pbx_outgoing_app(tech, cap, data, to, app, appdata, &reason, 1, l, n, vars, account, NULL, assignedids.uniqueid ? &assignedids : NULL);
+		res = ast_pbx_outgoing_app(tech, cap, data, to, app, appdata, &reason,
+				AST_OUTGOING_APP_WAIT, l, n, vars, account, NULL,
+				assignedids.uniqueid ? &assignedids : NULL);
 		ast_variables_destroy(vars);
 	} else {
 		if (exten && context && pi) {
-			res = ast_pbx_outgoing_exten(tech, cap, data, to, context, exten, pi, &reason, 1, l, n, vars, account, NULL, bridge_early, assignedids.uniqueid ? &assignedids : NULL);
+			res = ast_pbx_outgoing_exten(tech, cap, data, to,
+					context, exten, pi, &reason, AST_OUTGOING_EXT_WAIT,
+					l, n, vars, account, NULL, bridge_early,
+					assignedids.uniqueid ? &assignedids : NULL);
 			ast_variables_destroy(vars);
 		} else {
 			astman_send_error(s, m, "Originate with 'Exten' requires 'Context' and 'Priority'");
diff --git a/pbx/pbx_spool.c b/pbx/pbx_spool.c
index 4228be9..0b9c145 100644
--- a/pbx/pbx_spool.c
+++ b/pbx/pbx_spool.c
@@ -399,15 +399,17 @@
 	int res, reason;
 	if (!ast_strlen_zero(o->app)) {
 		ast_verb(3, "Attempting call on %s/%s for application %s(%s) (Retry %d)\n", o->tech, o->dest, o->app, o->data, o->retries);
-		res = ast_pbx_outgoing_app(o->tech, o->capabilities, o->dest, o->waittime * 1000,
-			o->app, o->data, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name,
+		res = ast_pbx_outgoing_app(o->tech, o->capabilities, o->dest,
+			o->waittime * 1000, o->app, o->data, &reason,
+			AST_OUTGOING_APP_WAIT_COMPLETE, o->cid_num, o->cid_name,
 			o->vars, o->account, NULL, NULL);
 	} else {
 		ast_verb(3, "Attempting call on %s/%s for %s@%s:%d (Retry %d)\n", o->tech, o->dest, o->exten, o->context,o->priority, o->retries);
 		res = ast_pbx_outgoing_exten(o->tech, o->capabilities, o->dest,
 			o->waittime * 1000, o->context, o->exten, o->priority, &reason,
-			2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, o->account, NULL,
-			ast_test_flag(&o->options, SPOOL_FLAG_EARLY_MEDIA), NULL);
+			AST_OUTGOING_EXT_WAIT_GOTO_FAILED, o->cid_num, o->cid_name,
+			o->vars, o->account, NULL, ast_test_flag(&o->options, SPOOL_FLAG_EARLY_MEDIA),
+			NULL);
 	}
 	if (res) {
 		ast_log(LOG_NOTICE, "Call failed to go through, reason (%d) %s\n", reason, ast_channel_reason2str(reason));
diff --git a/res/res_clioriginate.c b/res/res_clioriginate.c
index 3903b6c..73131b6 100644
--- a/res/res_clioriginate.c
+++ b/res/res_clioriginate.c
@@ -74,7 +74,9 @@
 		return CLI_FAILURE;
 	}
 	ast_format_cap_append(cap, ast_format_slin, 0);
-	ast_pbx_outgoing_app(chantech, cap, chandata, TIMEOUT * 1000, app, appdata, &reason, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+	ast_pbx_outgoing_app(chantech, cap, chandata, TIMEOUT * 1000, app, appdata,
+			&reason, AST_OUTGOING_APP_NO_WAIT, NULL, NULL, NULL, NULL,
+			NULL, NULL);
 	ao2_ref(cap, -1);
 
 	return CLI_SUCCESS;
@@ -118,7 +120,9 @@
 		return CLI_FAILURE;
 	}
 	ast_format_cap_append(cap, ast_format_slin, 0);
-	ast_pbx_outgoing_exten(chantech, cap, chandata, TIMEOUT * 1000, context, exten, 1, &reason, 0, NULL, NULL, NULL, NULL, NULL, 0, NULL);
+	ast_pbx_outgoing_exten(chantech, cap, chandata, TIMEOUT * 1000, context,
+			exten, 1, &reason, AST_OUTGOING_EXT_NO_WAIT, NULL, NULL,
+			NULL, NULL, NULL, 0, NULL);
 	ao2_ref(cap, -1);
 
 	return CLI_SUCCESS;

-- 
To view, visit https://gerrit.asterisk.org/4913
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8afbd06725e99610e02adb529137d4800c05345d
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>



More information about the asterisk-code-review mailing list