Merge "stasis.c: Use correct topic name in stasis_topic_pool_delete_topic" into 16

This commit is contained in:
Friendly Automation 2020-01-08 08:59:01 -06:00 committed by Gerrit Code Review
commit 932271939b
2 changed files with 18 additions and 2 deletions

View File

@ -940,7 +940,8 @@ struct stasis_topic *stasis_topic_pool_get_topic(struct stasis_topic_pool *pool,
* \brief Delete a topic from the topic pool
*
* \param pool Pool from which to delete the topic
* \param topic_name Name of the topic to delete
* \param topic_name Name of the topic to delete in the form of
* <pool_topic_name>/<topic_name> or just <topic_name>
*
* \since 13.24
* \since 15.6

View File

@ -1855,7 +1855,22 @@ struct stasis_topic_pool *stasis_topic_pool_create(struct stasis_topic *pooled_t
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);
/*
* The topic_name passed in could be a fully-qualified name like <pool_topic_name>/<topic_name>
* or just <topic_name>. If it's fully qualified, we need to skip past <pool_topic_name>
* name and search only on <topic_name>.
*/
const char *pool_topic_name = stasis_topic_name(pool->pool_topic);
int pool_topic_name_len = strlen(pool_topic_name);
const char *search_topic_name;
if (strncmp(pool_topic_name, topic_name, pool_topic_name_len) == 0) {
search_topic_name = topic_name + pool_topic_name_len + 1;
} else {
search_topic_name = topic_name;
}
ao2_find(pool->pool_container, search_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)