From 180bce79a0734c63ece4c6b860353b316d05f131 Mon Sep 17 00:00:00 2001 From: Corey Farrell Date: Mon, 23 Sep 2019 16:24:51 -0400 Subject: [PATCH] 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. Change-Id: Icc39ccbd815e1fa0f9106214373923acca5e896e --- main/stasis.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main/stasis.c b/main/stasis.c index 77b01a755e..917c09eec0 100644 --- a/main/stasis.c +++ b/main/stasis.c @@ -406,9 +406,10 @@ AO2_STRING_FIELD_HASH_FN(topic_proxy, name); 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 @@ static int link_topic_proxy(struct stasis_topic *topic, const char *name, const 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; } -- 2.21.0