[Asterisk-code-review] stasis.c: Use correct topic name in stasis_topic_pool_delete_topic (asterisk[17])

George Joseph asteriskteam at digium.com
Thu Jan 2 14:41:09 CST 2020


George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/13507 )


Change subject: stasis.c:  Use correct topic name in stasis_topic_pool_delete_topic
......................................................................

stasis.c:  Use correct topic name in stasis_topic_pool_delete_topic

When a topic is created for an object, its name is only
<object>:<uniqueid>
For example:
bridge:cb68b3a8-fce7-4738-8a17-d7847562f020

When a topic is added to a pool, its name has the pool's topic
name prepended.  For example:
bridge:all/bridge:cb68b3a8-fce7-4738-8a17-d7847562f020

The topic_pool_entry's name however, is only what was passed
in to stasis_topic_pool_get_topic which is
bridge:cb68b3a8-fce7-4738-8a17-d7847562f020
That's actually correct because the entry is qualified by the
pool that's in.

When you're ready to delete the entry from the pool, you retrieve
the tropic name from the object but since it now has the pool's
topic name prepended, it won't be found in the pool container.

Fix:

* Modified stasis_topic_pool_delete_topic() to skip past the
pool topic's name when searching the container for a pool entry.

NOTE: This fix is only needed in the Asterisk 17 and master branches.

ASTERISK-28633
Reported by: Joeran Vinzens

Change-Id: I4396aa69dd83e4ab84c5b91b39293cfdbcf483e6
---
M main/stasis.c
1 file changed, 5 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/07/13507/1

diff --git a/main/stasis.c b/main/stasis.c
index 9d7c11f..696d067 100644
--- a/main/stasis.c
+++ b/main/stasis.c
@@ -1855,7 +1855,11 @@
 
 void stasis_topic_pool_delete_topic(struct stasis_topic_pool *pool, const char *topic_name)
 {
-	ao2_find(pool->pool_container, topic_name, OBJ_SEARCH_KEY | OBJ_NODATA | OBJ_UNLINK);
+	char *temp_topic_name = ast_strdupa(topic_name);
+	int pool_topic_name_len = strlen(stasis_topic_name(pool->pool_topic)); /* Safe */
+	char *new_topic_name = &temp_topic_name[pool_topic_name_len] + 1;
+
+	ao2_find(pool->pool_container, new_topic_name, OBJ_SEARCH_KEY | OBJ_NODATA | OBJ_UNLINK);
 }
 
 struct stasis_topic *stasis_topic_pool_get_topic(struct stasis_topic_pool *pool, const char *topic_name)

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

Gerrit-Project: asterisk
Gerrit-Branch: 17
Gerrit-Change-Id: I4396aa69dd83e4ab84c5b91b39293cfdbcf483e6
Gerrit-Change-Number: 13507
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200102/bb8ed1c4/attachment.html>


More information about the asterisk-code-review mailing list