[asterisk-commits] app originate: Set ORIGINATE STATUS correctly on failure (asterisk[14])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Oct 11 15:14:19 CDT 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/6730 )

Change subject: app_originate: Set ORIGINATE_STATUS correctly on failure
......................................................................

app_originate: Set ORIGINATE_STATUS correctly on failure

We were ignoring the return value from ast_pbx_outgoing_exten() and
ast_pbx_outgoing_app() which could fail before setting the reason code.
This resulted in failures being reported as success.

ASTERISK-25266 #close
Reported by: Allen Ford

Change-Id: Idf16237b7e41b527d2c69c865829128686beeb3b
---
M apps/app_originate.c
1 file changed, 23 insertions(+), 9 deletions(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, but someone else must approve
  Richard Mudgett: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/apps/app_originate.c b/apps/app_originate.c
index 88245f0..6093f30 100644
--- a/apps/app_originate.c
+++ b/apps/app_originate.c
@@ -110,6 +110,7 @@
 	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 @@
 		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 @@
 		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 @@
 	ao2_cleanup(cap_slin);
 	ast_autoservice_stop(chan);
 
-	return res;
+	return continue_in_dialplan ? 0 : -1;
 }
 
 static int unload_module(void)

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

Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-MessageType: merged
Gerrit-Change-Id: Idf16237b7e41b527d2c69c865829128686beeb3b
Gerrit-Change-Number: 6730
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-commits/attachments/20171011/35e0a004/attachment-0001.html>


More information about the asterisk-commits mailing list