[Asterisk-code-review] stasis: Pass bumped topic_all reference to proxy_dtor. (...asterisk[16])

Joshua Colp asteriskteam at digium.com
Fri Oct 4 05:22:56 CDT 2019


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/c/asterisk/+/12993 )

Change subject: stasis: Pass bumped topic_all reference to proxy_dtor.
......................................................................

stasis: Pass bumped topic_all reference to proxy_dtor.

This avoids use of the global variable and ensures topic_all remains
active until all topics are freed.

ASTERISK-28553
patches:
  ASTERISK-28553.patch by coreyfarrell (license 5909)

Change-Id: I9a8cd8977f3c3a6aa00783f8336d2cfb9c2820f1
---
M main/stasis.c
1 file changed, 5 insertions(+), 3 deletions(-)

Approvals:
  Benjamin Keith Ford: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Joshua Colp: Approved for Submit



diff --git a/main/stasis.c b/main/stasis.c
index 1947481..618bee0 100644
--- a/main/stasis.c
+++ b/main/stasis.c
@@ -406,9 +406,10 @@
 AO2_STRING_FIELD_CMP_FN(topic_proxy, name);
 AO2_STRING_FIELD_CASE_SORT_FN(topic_proxy, name);
 
-static void proxy_dtor(void *weakproxy, void *data)
+static void proxy_dtor(void *weakproxy, void *container)
 {
-	ao2_unlink(topic_all, weakproxy);
+	ao2_unlink(container, weakproxy);
+	ao2_cleanup(container);
 }
 
 /* Forward declarations for the tightly-coupled subscription object */
@@ -537,9 +538,10 @@
 		return -1;
 	}
 
-	if (ao2_weakproxy_subscribe(proxy, proxy_dtor, NULL, OBJ_NOLOCK)) {
+	if (ao2_weakproxy_subscribe(proxy, proxy_dtor, ao2_bump(topic_all), OBJ_NOLOCK)) {
 		ao2_cleanup(proxy);
 		ao2_unlock(topic_all);
+		ao2_cleanup(topic_all);
 
 		return -1;
 	}

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

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I9a8cd8977f3c3a6aa00783f8336d2cfb9c2820f1
Gerrit-Change-Number: 12993
Gerrit-PatchSet: 1
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20191004/f1fbd25b/attachment.html>


More information about the asterisk-code-review mailing list