[asterisk-commits] channel.c: Fix NewCallerid AMI event not been sent on Caller... (asterisk[11])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Sep 28 21:05:18 CDT 2015


Matt Jordan has submitted this change and it was merged.

Change subject: channel.c: Fix NewCallerid AMI event not been sent on Caller ID change
......................................................................


channel.c: Fix NewCallerid AMI event not been sent on Caller ID change

Currently, NewCallerid is sent only when pointers to number or name
strings change, which is not always the case. The newly allocated string
may use the same memory, so pointers match, while the content
is different. As a result, Caller ID updates are often not reported.

With this patch, actual strings are compared, not the pointers.

ASTERISK-25427 #close
Reported by: Ivan Poddubny

Change-Id: I2a1ac3a842f0e092c6058d1cd3e35443bece1b36
---
M main/channel.c
1 file changed, 16 insertions(+), 9 deletions(-)

Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/main/channel.c b/main/channel.c
index f26f865..ef50e94 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -7388,8 +7388,10 @@
 
 void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update)
 {
-	const char *pre_set_number;
-	const char *pre_set_name;
+	const char *old_number;
+	const char *old_name;
+	const char *new_number;
+	const char *new_name;
 
 	if (ast_channel_caller(chan) == caller) {
 		/* Don't set to self */
@@ -7397,14 +7399,19 @@
 	}
 
 	ast_channel_lock(chan);
-	pre_set_number =
-		S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL);
-	pre_set_name = S_COR(ast_channel_caller(chan)->id.name.valid, ast_channel_caller(chan)->id.name.str, NULL);
+	old_number = ast_strdupa(S_COR(ast_channel_caller(chan)->id.number.valid,
+		ast_channel_caller(chan)->id.number.str, ""));
+	old_name = ast_strdupa(S_COR(ast_channel_caller(chan)->id.name.valid,
+		ast_channel_caller(chan)->id.name.str, ""));
+
 	ast_party_caller_set(ast_channel_caller(chan), caller, update);
-	if (S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL)
-			!= pre_set_number
-		|| S_COR(ast_channel_caller(chan)->id.name.valid, ast_channel_caller(chan)->id.name.str, NULL)
-			!= pre_set_name) {
+
+	new_number = S_COR(ast_channel_caller(chan)->id.number.valid,
+		ast_channel_caller(chan)->id.number.str, "");
+	new_name = S_COR(ast_channel_caller(chan)->id.name.valid,
+		ast_channel_caller(chan)->id.name.str, "");
+
+	if (0 != strcmp(old_number, new_number) || 0 != strcmp(old_name, new_name)) {
 		/* The caller id name or number changed. */
 		report_new_callerid(chan);
 	}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I2a1ac3a842f0e092c6058d1cd3e35443bece1b36
Gerrit-PatchSet: 3
Gerrit-Project: asterisk
Gerrit-Branch: 11
Gerrit-Owner: Ivan Poddubny <ivan.poddubny at gmail.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Ivan Poddubny <ivan.poddubny at gmail.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-commits mailing list