[Asterisk-code-review] res_pjsip: Fix multiple of the same contact in "pjsip show contacts". (...asterisk[13])

George Joseph asteriskteam at digium.com
Mon Aug 5 07:22:19 CDT 2019


George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/c/asterisk/+/11663 )

Change subject: res_pjsip: Fix multiple of the same contact in "pjsip show contacts".
......................................................................

res_pjsip: Fix multiple of the same contact in "pjsip show contacts".

The code for gathering contacts could result in the same contact
being retrieved and added to the list multiple times. The container
which stores the contacts to display will now only allow a contact
to be added to it once instead of multiple times.

ASTERISK-28228

Change-Id: I805185cfcec03340f57d2b9e6cc43c49401812df
---
M res/res_pjsip/location.c
1 file changed, 5 insertions(+), 1 deletion(-)

Approvals:
  Sean Bright: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved; Approved for Submit



diff --git a/res/res_pjsip/location.c b/res/res_pjsip/location.c
index 3e5b97f..2a173da 100644
--- a/res/res_pjsip/location.c
+++ b/res/res_pjsip/location.c
@@ -1046,7 +1046,11 @@
 		return NULL;
 	}
 
-	contacts_container = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_NOLOCK, 0,
+	/* Retrieving all the contacts may result in finding the same contact multiple
+	 * times. So that they don't get displayed multiple times we only allow a
+	 * single one to be placed into the container.
+	 */
+	contacts_container = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_NOLOCK, AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT,
 		cli_contact_sort, cli_contact_compare);
 	if (!contacts_container) {
 		return NULL;

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

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: I805185cfcec03340f57d2b9e6cc43c49401812df
Gerrit-Change-Number: 11663
Gerrit-PatchSet: 1
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190805/346d8565/attachment.html>


More information about the asterisk-code-review mailing list