[Asterisk-code-review] apps/app_dial.c: HANGUPCAUSE reason code for CANCEL is set to AST_CAU... (asterisk[master])

Friendly Automation asteriskteam at digium.com
Mon Dec 6 09:17:18 CST 2021


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/16345 )

Change subject: apps/app_dial.c: HANGUPCAUSE reason code for CANCEL is set to AST_CAUSE_NORMAL_CLEARING
......................................................................

apps/app_dial.c: HANGUPCAUSE reason code for CANCEL is set to AST_CAUSE_NORMAL_CLEARING

changed that when we recive a CANCEL that we set HANGUPCAUSE to AST_CAUSE_NORMAL_CLEARING

ASTERISK-28053
Reported by: roadkill

Change-Id: Ib653aec2282f55b59d87484391cc07c8e6612b89
---
M apps/app_dial.c
1 file changed, 16 insertions(+), 6 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/apps/app_dial.c b/apps/app_dial.c
index 1f3cb8b..526a3af 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -1146,6 +1146,7 @@
 	char privcid[256];
 	char privintro[1024];
 	char status[256];
+	int canceled;
 };
 
 static void publish_dial_end_event(struct ast_channel *in, struct dial_head *out_chans, struct ast_channel *exception, const char *status)
@@ -1718,6 +1719,7 @@
 				/* Got hung up */
 				*to = -1;
 				strcpy(pa->status, "CANCEL");
+				pa->canceled = 1;
 				publish_dial_end_event(in, out_chans, NULL, pa->status);
 				if (f) {
 					if (f->data.uint32) {
@@ -1742,6 +1744,7 @@
 						*to = 0;
 						*result = f->subclass.integer;
 						strcpy(pa->status, "CANCEL");
+						pa->canceled = 1;
 						publish_dial_end_event(in, out_chans, NULL, pa->status);
 						ast_frfree(f);
 						ast_channel_unlock(in);
@@ -1759,6 +1762,7 @@
 					ast_verb(3, "User requested call disconnect.\n");
 					*to = 0;
 					strcpy(pa->status, "CANCEL");
+					pa->canceled = 1;
 					publish_dial_end_event(in, out_chans, NULL, pa->status);
 					ast_frfree(f);
 					if (is_cc_recall) {
@@ -2241,7 +2245,7 @@
 	struct ast_channel *peer = NULL;
 	int to; /* timeout */
 	struct cause_args num = { chan, 0, 0, 0 };
-	int cause;
+	int cause, hanguptreecause = -1;
 
 	struct ast_bridge_config config = { { 0, } };
 	struct timeval calldurationlimit = { 0, };
@@ -2250,6 +2254,7 @@
 		.sentringing = 0,
 		.privdb_val = 0,
 		.status = "INVALIDARGS",
+		.canceled = 0,
 	};
 	int sentringing = 0, moh = 0;
 	const char *outbound_group = NULL;
@@ -3350,11 +3355,16 @@
 	}
 
 	ast_channel_early_bridge(chan, NULL);
-	 /* forward 'answered elsewhere' if we received it */
-	hanguptree(&out_chans, NULL,
-		ast_channel_hangupcause(chan) == AST_CAUSE_ANSWERED_ELSEWHERE
-		|| ast_test_flag64(&opts, OPT_CANCEL_ELSEWHERE)
-		? AST_CAUSE_ANSWERED_ELSEWHERE : -1);
+	/* forward 'answered elsewhere' if we received it */
+	if (ast_channel_hangupcause(chan) == AST_CAUSE_ANSWERED_ELSEWHERE || ast_test_flag64(&opts, OPT_CANCEL_ELSEWHERE)) {
+		hanguptreecause = AST_CAUSE_ANSWERED_ELSEWHERE;
+	} else if (pa.canceled) { /* Caller canceled */
+		if (ast_channel_hangupcause(chan))
+			hanguptreecause = ast_channel_hangupcause(chan);
+		else
+			hanguptreecause = AST_CAUSE_NORMAL_CLEARING;
+	}
+	hanguptree(&out_chans, NULL, hanguptreecause);
 	pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status);
 	ast_debug(1, "Exiting with DIALSTATUS=%s.\n", pa.status);
 

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/16345
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ib653aec2282f55b59d87484391cc07c8e6612b89
Gerrit-Change-Number: 16345
Gerrit-PatchSet: 12
Gerrit-Owner: Mark Petersen <bugs.digium.com at zombie.dk>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Mark Petersen <bugs.digium.com at zombie.dk>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20211206/0661192c/attachment.html>


More information about the asterisk-code-review mailing list