[Asterisk-code-review] stasis.c: Added topic all container (asterisk[master])

sungtae kim asteriskteam at digium.com
Sat Jan 26 16:01:13 CST 2019


sungtae kim has uploaded this change for review. ( https://gerrit.asterisk.org/10929


Change subject: stasis.c: Added topic_all container
......................................................................

stasis.c: Added topic_all container

Added topic_all container for centralizing the topic. This makes more
easier to managing the topics.

Change-Id: Ie86d125d2966f93de74ee00f47ae6fbc8c081c5f
---
M include/asterisk/stasis.h
M main/app.c
M main/cdr.c
M main/cel.c
M main/channel_internal_api.c
M main/devicestate.c
M main/manager.c
M main/parking.c
M main/presencestate.c
M main/rtp_engine.c
M main/security_events.c
M main/stasis.c
M main/stasis_bridges.c
M main/stasis_cache.c
M main/stasis_cache_pattern.c
M main/stasis_channels.c
M main/stasis_system.c
M main/test.c
M res/res_corosync.c
M res/stasis/app.c
M tests/test_stasis.c
21 files changed, 168 insertions(+), 50 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/29/10929/1

diff --git a/include/asterisk/stasis.h b/include/asterisk/stasis.h
index 09db9ea..41997b9 100644
--- a/include/asterisk/stasis.h
+++ b/include/asterisk/stasis.h
@@ -518,6 +518,18 @@
 struct stasis_topic *stasis_topic_create(const char *name);
 
 /*!
+ * \brief Release a topic
+ * \param topic Topic to release.
+ */
+void stasis_topic_release(struct stasis_topic *topic);
+
+/*!
+ * \brief Get a topic of given name.
+ * \param name Name of topic.
+ */
+struct stasis_topic *stasis_topic_get_by_name(const char *name);
+
+/*!
  * \brief Return the name of a topic.
  * \param topic Topic.
  * \return Name of the topic.
diff --git a/main/app.c b/main/app.c
index ec74490..c7b0839 100644
--- a/main/app.c
+++ b/main/app.c
@@ -3407,11 +3407,11 @@
 {
 	ao2_cleanup(queue_topic_pool);
 	queue_topic_pool = NULL;
-	ao2_cleanup(queue_topic_all);
+	stasis_topic_release(queue_topic_all);
 	queue_topic_all = NULL;
 	ao2_cleanup(mwi_topic_pool);
 	mwi_topic_pool = NULL;
-	ao2_cleanup(mwi_topic_all);
+	stasis_topic_release(mwi_topic_all);
 	mwi_topic_all = NULL;
 	ao2_cleanup(mwi_state_cache);
 	mwi_state_cache = NULL;
diff --git a/main/cdr.c b/main/cdr.c
index 462c3e6..ad15c3d 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -4350,7 +4350,7 @@
 	stasis_message_router_unsubscribe_and_join(stasis_router);
 	stasis_router = NULL;
 
-	ao2_cleanup(cdr_topic);
+	stasis_topic_release(cdr_topic);
 	cdr_topic = NULL;
 
 	STASIS_MESSAGE_TYPE_CLEANUP(cdr_sync_message_type);
diff --git a/main/cel.c b/main/cel.c
index 95376db..817fc1d 100644
--- a/main/cel.c
+++ b/main/cel.c
@@ -1399,9 +1399,9 @@
 
 static void destroy_subscriptions(void)
 {
-	ao2_cleanup(cel_aggregation_topic);
+	stasis_topic_release(cel_aggregation_topic);
 	cel_aggregation_topic = NULL;
-	ao2_cleanup(cel_topic);
+	stasis_topic_release(cel_topic);
 	cel_topic = NULL;
 
 	cel_channel_forwarder = stasis_forward_cancel(cel_channel_forwarder);
diff --git a/main/channel_internal_api.c b/main/channel_internal_api.c
index 22a2bb6..0824dae 100644
--- a/main/channel_internal_api.c
+++ b/main/channel_internal_api.c
@@ -1475,7 +1475,7 @@
 	chan->channel_forward = stasis_forward_cancel(chan->channel_forward);
 	chan->endpoint_forward = stasis_forward_cancel(chan->endpoint_forward);
 
-	ao2_cleanup(chan->topic);
+	stasis_topic_release(chan->topic);
 	chan->topic = NULL;
 
 	ast_channel_internal_set_stream_topology(chan, NULL);
@@ -1535,7 +1535,7 @@
 	chan->channel_forward = stasis_forward_all(ast_channel_topic(chan),
 		ast_channel_topic_all());
 	if (!chan->channel_forward) {
-		ao2_ref(chan->topic, -1);
+		stasis_topic_release(chan->topic);
 		chan->topic = NULL;
 		return -1;
 	}
diff --git a/main/devicestate.c b/main/devicestate.c
index b6c740c..d8281f1 100644
--- a/main/devicestate.c
+++ b/main/devicestate.c
@@ -889,7 +889,7 @@
 	ao2_cleanup(device_state_topic_pool);
 	device_state_topic_pool = NULL;
 
-	ao2_cleanup(device_state_topic_all);
+	stasis_topic_release(device_state_topic_all);
 	device_state_topic_all = NULL;
 
 	STASIS_MESSAGE_TYPE_CLEANUP(ast_device_state_message_type);
diff --git a/main/manager.c b/main/manager.c
index 0c715e4..13618db 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -8846,7 +8846,7 @@
 	rtp_topic_forwarder = NULL;
 	stasis_forward_cancel(security_topic_forwarder);
 	security_topic_forwarder = NULL;
-	ao2_cleanup(manager_topic);
+	stasis_topic_release(manager_topic);
 	manager_topic = NULL;
 	STASIS_MESSAGE_TYPE_CLEANUP(ast_manager_get_generic_type);
 
diff --git a/main/parking.c b/main/parking.c
index bf0d0b6..4005758 100644
--- a/main/parking.c
+++ b/main/parking.c
@@ -46,7 +46,7 @@
 static void parking_stasis_cleanup(void)
 {
 	STASIS_MESSAGE_TYPE_CLEANUP(ast_parked_call_type);
-	ao2_cleanup(parking_topic);
+	stasis_topic_release(parking_topic);
 	parking_topic = NULL;
 }
 
diff --git a/main/presencestate.c b/main/presencestate.c
index 65b7f69..cce6efd 100644
--- a/main/presencestate.c
+++ b/main/presencestate.c
@@ -483,7 +483,7 @@
 
 static void presence_state_engine_cleanup(void)
 {
-	ao2_cleanup(presence_state_topic_all);
+	stasis_topic_release(presence_state_topic_all);
 	presence_state_topic_all = NULL;
 	ao2_cleanup(presence_state_cache);
 	presence_state_cache = NULL;
diff --git a/main/rtp_engine.c b/main/rtp_engine.c
index fd1613c..7241521 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -3512,7 +3512,7 @@
 {
 	int x;
 
-	ao2_cleanup(rtp_topic);
+	stasis_topic_release(rtp_topic);
 	rtp_topic = NULL;
 	STASIS_MESSAGE_TYPE_CLEANUP(ast_rtp_rtcp_received_type);
 	STASIS_MESSAGE_TYPE_CLEANUP(ast_rtp_rtcp_sent_type);
diff --git a/main/security_events.c b/main/security_events.c
index 37dce02..9e34604 100644
--- a/main/security_events.c
+++ b/main/security_events.c
@@ -474,7 +474,7 @@
 
 static void security_stasis_cleanup(void)
 {
-	ao2_cleanup(security_topic);
+	stasis_topic_release(security_topic);
 	security_topic = NULL;
 
 	STASIS_MESSAGE_TYPE_CLEANUP(ast_security_event_type);
diff --git a/main/stasis.c b/main/stasis.c
index f05f5ff..4c53d46 100644
--- a/main/stasis.c
+++ b/main/stasis.c
@@ -307,6 +307,9 @@
 
 STASIS_MESSAGE_TYPE_DEFN(stasis_subscription_change_type);
 
+#define TOPIC_ALL_BUCKETS 997
+
+
 #ifdef AST_DEVMODE
 
 /*! The number of buckets to use for topic statistics */
@@ -367,9 +370,21 @@
 #endif
 
 	/*! Name of the topic */
-	char name[0];
+//	char name[0];
+	char *name;
+
+	/*! Uniqueid of the topic */
+//	char uniqueid[0];
+	char *uniqueid;
+
+	char buf[0];
 };
 
+struct ao2_container *topic_all;
+
+AO2_STRING_FIELD_HASH_FN(stasis_topic, name);
+AO2_STRING_FIELD_CMP_FN(stasis_topic, name);
+
 /* Forward declarations for the tightly-coupled subscription object */
 static int topic_add_subscription(struct stasis_topic *topic,
 	struct stasis_subscription *sub);
@@ -421,17 +436,36 @@
 }
 #endif
 
+void stasis_topic_release(struct stasis_topic *topic)
+{
+	if (!topic) {
+		return;
+	}
+
+	ao2_unlink(topic_all, topic);
+	ao2_ref(topic, -1);
+
+	return;
+}
+
 struct stasis_topic *stasis_topic_create(const char *name)
 {
 	struct stasis_topic *topic;
+	char buf[36 + 1];
 	int res = 0;
 
-	topic = ao2_t_alloc(sizeof(*topic) + strlen(name) + 1, topic_dtor, name);
+	ast_uuid_generate_str(buf, sizeof(buf));
+
+	topic = ao2_t_alloc(sizeof(*topic) + strlen(name) + 1 + sizeof(buf) + 1, topic_dtor, name);
 	if (!topic) {
 		return NULL;
 	}
 
+	topic->name = topic->buf;
+	topic->uniqueid = topic->buf + strlen(name) + 1;
 	strcpy(topic->name, name); /* SAFE */
+	strcpy(topic->uniqueid, buf);
+
 	res |= AST_VECTOR_INIT(&topic->subscribers, INITIAL_SUBSCRIBERS_MAX);
 	res |= AST_VECTOR_INIT(&topic->upstream_topics, 0);
 #ifdef AST_DEVMODE
@@ -445,9 +479,17 @@
 		return NULL;
 	}
 
+
+	ao2_link(topic_all, topic);
+
 	return topic;
 }
 
+struct stasis_topic *stasis_topic_get_by_name(const char *name)
+{
+	return ao2_find(topic_all, name, OBJ_SEARCH_KEY);
+}
+
 const char *stasis_topic_name(const struct stasis_topic *topic)
 {
 	return topic->name;
@@ -533,7 +575,7 @@
 	 * be bad. */
 	ast_assert(stasis_subscription_is_done(sub));
 
-	ao2_cleanup(sub->topic);
+	stasis_topic_release(sub->topic);
 	sub->topic = NULL;
 	ast_taskprocessor_unreference(sub->mailbox);
 	sub->mailbox = NULL;
@@ -2067,6 +2109,57 @@
 
 /*! @} */
 
+/*!
+ * \internal
+ * \brief CLI command implementation for 'stasis show topics'
+ */
+static char *stasis_show_topics(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	struct ao2_iterator iter;
+	struct stasis_topic *topic;
+	int count = 0;
+#define FMT_HEADERS		"%-64s %-64s\n"
+#define FMT_FIELDS		"%-64s %-64s\n"
+
+	switch (cmd) {
+	case CLI_INIT:
+		e->command = "stasis show topics";
+		e->usage =
+			"Usage: stasis show topics\n"
+			"	Shows a list of topics\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;
+	}
+
+	if (a->argc != e->args) {
+		return CLI_SHOWUSAGE;
+	}
+
+	ast_cli(a->fd, "\n" FMT_HEADERS, "Name", "Uniqueid");
+
+	iter = ao2_iterator_init(topic_all, 0);
+	while ((topic = ao2_iterator_next(&iter))) {
+		ast_cli(a->fd, FMT_FIELDS, topic->name, topic->uniqueid);
+		ao2_ref(topic, -1);
+		++count;
+	}
+	ao2_iterator_destroy(&iter);
+
+	ast_cli(a->fd, "\n%d Total topics\n\n", count);
+
+#undef FMT_HEADERS
+#undef FMT_FIELDS
+
+	return CLI_SUCCESS;
+}
+
+
+static struct ast_cli_entry cli_stasis[] = {
+	AST_CLI_DEFINE(stasis_show_topics, "Show all topics"),
+};
+
+
 #ifdef AST_DEVMODE
 
 /*!
@@ -2519,6 +2612,9 @@
 	ao2_cleanup(subscription_statistics);
 	ao2_cleanup(topic_statistics);
 #endif
+	ast_cli_unregister_multiple(cli_stasis, ARRAY_LEN(cli_stasis));
+	ao2_cleanup(topic_all);
+	topic_all = NULL;
 	ast_threadpool_shutdown(pool);
 	pool = NULL;
 	STASIS_MESSAGE_TYPE_CLEANUP(stasis_subscription_change_type);
@@ -2613,6 +2709,16 @@
 		return -1;
 	}
 
+	topic_all = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, TOPIC_ALL_BUCKETS,
+			stasis_topic_hash_fn, 0, stasis_topic_cmp_fn);
+	if (!topic_all) {
+		return -1;
+	}
+
+	if (ast_cli_register_multiple(cli_stasis, ARRAY_LEN(cli_stasis))) {
+		return -1;
+	}
+
 #ifdef AST_DEVMODE
 	/* Statistics information is stored separately so that we don't alter or interrupt the lifetime of the underlying
 	 * topic or subscripton.
diff --git a/main/stasis_bridges.c b/main/stasis_bridges.c
index bed28ba..f84aaa5 100644
--- a/main/stasis_bridges.c
+++ b/main/stasis_bridges.c
@@ -1353,7 +1353,7 @@
 
 	ao2_cleanup(bridge_topic_pool);
 	bridge_topic_pool = NULL;
-	ao2_cleanup(bridge_topic_all);
+	stasis_topic_release(bridge_topic_all);
 	bridge_topic_all = NULL;
 }
 
diff --git a/main/stasis_cache.c b/main/stasis_cache.c
index ee8a1dd..3f95ff3 100644
--- a/main/stasis_cache.c
+++ b/main/stasis_cache.c
@@ -76,7 +76,7 @@
 	caching_topic->sub = NULL;
 	ao2_cleanup(caching_topic->cache);
 	caching_topic->cache = NULL;
-	ao2_cleanup(caching_topic->topic);
+	stasis_topic_release(caching_topic->topic);
 	caching_topic->topic = NULL;
 	ao2_cleanup(caching_topic->original_topic);
 	caching_topic->original_topic = NULL;
diff --git a/main/stasis_cache_pattern.c b/main/stasis_cache_pattern.c
index 04d8164..14a8c8e 100644
--- a/main/stasis_cache_pattern.c
+++ b/main/stasis_cache_pattern.c
@@ -52,9 +52,9 @@
 {
 	struct stasis_cp_all *all = obj;
 
-	ao2_cleanup(all->topic);
+	stasis_topic_release(all->topic);
 	all->topic = NULL;
-	ao2_cleanup(all->topic_cached);
+	stasis_topic_release(all->topic_cached);
 	all->topic_cached = NULL;
 	ao2_cleanup(all->cache);
 	all->cache = NULL;
@@ -131,7 +131,7 @@
 	ast_assert(one->forward_topic_to_all == NULL);
 	ast_assert(one->forward_cached_to_all == NULL);
 
-	ao2_cleanup(one->topic);
+	stasis_topic_release(one->topic);
 	one->topic = NULL;
 }
 
diff --git a/main/stasis_channels.c b/main/stasis_channels.c
index d39fb08..28b6157 100644
--- a/main/stasis_channels.c
+++ b/main/stasis_channels.c
@@ -1623,7 +1623,7 @@
 
 static void stasis_channels_cleanup(void)
 {
-	ao2_cleanup(channel_topic_all);
+	stasis_topic_release(channel_topic_all);
 	channel_topic_all = NULL;
 	ao2_cleanup(channel_cache);
 	channel_cache = NULL;
diff --git a/main/stasis_system.c b/main/stasis_system.c
index 961a2b0..3adec12 100644
--- a/main/stasis_system.c
+++ b/main/stasis_system.c
@@ -352,7 +352,7 @@
 /*! \brief Cleanup the \ref stasis system level items */
 static void stasis_system_cleanup(void)
 {
-	ao2_cleanup(system_topic);
+	stasis_topic_release(system_topic);
 	system_topic = NULL;
 	STASIS_MESSAGE_TYPE_CLEANUP(ast_network_change_type);
 	STASIS_MESSAGE_TYPE_CLEANUP(ast_system_registry_type);
diff --git a/main/test.c b/main/test.c
index 2abe698..38093a3 100644
--- a/main/test.c
+++ b/main/test.c
@@ -1212,7 +1212,7 @@
 {
 	AST_TEST_UNREGISTER(test_registrations);
 	ast_cli_unregister_multiple(test_cli, ARRAY_LEN(test_cli));
-	ao2_cleanup(test_suite_topic);
+	stasis_topic_release(test_suite_topic);
 	test_suite_topic = NULL;
 	STASIS_MESSAGE_TYPE_CLEANUP(ast_test_suite_message_type);
 }
diff --git a/res/res_corosync.c b/res/res_corosync.c
index bf172e3..4f33dde 100644
--- a/res/res_corosync.c
+++ b/res/res_corosync.c
@@ -1074,7 +1074,7 @@
 	}
 
 	if (corosync_aggregate_topic) {
-		ao2_t_ref(corosync_aggregate_topic, -1, "Dispose of topic on cleanup");
+		stasis_topic_release(corosync_aggregate_topic);
 		corosync_aggregate_topic = NULL;
 	}
 
diff --git a/res/stasis/app.c b/res/stasis/app.c
index 585edda..2ee73a2 100644
--- a/res/stasis/app.c
+++ b/res/stasis/app.c
@@ -290,7 +290,7 @@
 	ast_assert(app->bridge_router == NULL);
 	ast_assert(app->endpoint_router == NULL);
 
-	ao2_cleanup(app->topic);
+	stasis_topic_release(app->topic);
 	app->topic = NULL;
 	ao2_cleanup(app->forwards);
 	app->forwards = NULL;
diff --git a/tests/test_stasis.c b/tests/test_stasis.c
index e620039..1c5fd30 100644
--- a/tests/test_stasis.c
+++ b/tests/test_stasis.c
@@ -313,7 +313,7 @@
 
 AST_TEST_DEFINE(subscription_messages)
 {
-	RAII_VAR(struct stasis_topic *, topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_topic *, topic, NULL, stasis_topic_release);
 	RAII_VAR(struct stasis_subscription *, uut, NULL, stasis_unsubscribe);
 	RAII_VAR(char *, test_data, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_message_type *, test_message_type, NULL, ao2_cleanup);
@@ -368,7 +368,7 @@
 
 AST_TEST_DEFINE(subscription_pool_messages)
 {
-	RAII_VAR(struct stasis_topic *, topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_topic *, topic, NULL, stasis_topic_release);
 	RAII_VAR(struct stasis_subscription *, uut, NULL, stasis_unsubscribe);
 	RAII_VAR(char *, test_data, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_message_type *, test_message_type, NULL, ao2_cleanup);
@@ -423,7 +423,7 @@
 
 AST_TEST_DEFINE(publish)
 {
-	RAII_VAR(struct stasis_topic *, topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_topic *, topic, NULL, stasis_topic_release);
 	RAII_VAR(struct stasis_subscription *, uut, NULL, stasis_unsubscribe);
 	RAII_VAR(char *, test_data, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_message_type *, test_message_type, NULL, ao2_cleanup);
@@ -470,7 +470,7 @@
 
 AST_TEST_DEFINE(publish_sync)
 {
-	RAII_VAR(struct stasis_topic *, topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_topic *, topic, NULL, stasis_topic_release);
 	RAII_VAR(struct stasis_subscription *, uut, NULL, stasis_unsubscribe);
 	RAII_VAR(char *, test_data, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_message_type *, test_message_type, NULL, ao2_cleanup);
@@ -517,7 +517,7 @@
 
 AST_TEST_DEFINE(publish_pool)
 {
-	RAII_VAR(struct stasis_topic *, topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_topic *, topic, NULL, stasis_topic_release);
 	RAII_VAR(struct stasis_subscription *, uut, NULL, stasis_unsubscribe);
 	RAII_VAR(char *, test_data, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_message_type *, test_message_type, NULL, ao2_cleanup);
@@ -566,7 +566,7 @@
 
 AST_TEST_DEFINE(unsubscribe_stops_messages)
 {
-	RAII_VAR(struct stasis_topic *, topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_topic *, topic, NULL, stasis_topic_release);
 	RAII_VAR(struct consumer *, consumer, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_subscription *, uut, NULL, stasis_unsubscribe);
 	RAII_VAR(char *, test_data, NULL, ao2_cleanup);
@@ -612,8 +612,8 @@
 
 AST_TEST_DEFINE(forward)
 {
-	RAII_VAR(struct stasis_topic *, parent_topic, NULL, ao2_cleanup);
-	RAII_VAR(struct stasis_topic *, topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_topic *, parent_topic, NULL, stasis_topic_release);
+	RAII_VAR(struct stasis_topic *, topic, NULL, stasis_topic_release);
 
 	RAII_VAR(struct consumer *, parent_consumer, NULL, ao2_cleanup);
 	RAII_VAR(struct consumer *, consumer, NULL, ao2_cleanup);
@@ -678,9 +678,9 @@
 
 AST_TEST_DEFINE(interleaving)
 {
-	RAII_VAR(struct stasis_topic *, parent_topic, NULL, ao2_cleanup);
-	RAII_VAR(struct stasis_topic *, topic1, NULL, ao2_cleanup);
-	RAII_VAR(struct stasis_topic *, topic2, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_topic *, parent_topic, NULL, stasis_topic_release);
+	RAII_VAR(struct stasis_topic *, topic1, NULL, stasis_topic_release);
+	RAII_VAR(struct stasis_topic *, topic2, NULL, stasis_topic_release);
 
 	RAII_VAR(struct stasis_message_type *, test_message_type, NULL, ao2_cleanup);
 
@@ -761,9 +761,9 @@
 
 AST_TEST_DEFINE(subscription_interleaving)
 {
-	RAII_VAR(struct stasis_topic *, parent_topic, NULL, ao2_cleanup);
-	RAII_VAR(struct stasis_topic *, topic1, NULL, ao2_cleanup);
-	RAII_VAR(struct stasis_topic *, topic2, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_topic *, parent_topic, NULL, stasis_topic_release);
+	RAII_VAR(struct stasis_topic *, topic1, NULL, stasis_topic_release);
+	RAII_VAR(struct stasis_topic *, topic2, NULL, stasis_topic_release);
 
 	RAII_VAR(struct stasis_message_type *, test_message_type, NULL, ao2_cleanup);
 
@@ -986,7 +986,7 @@
 AST_TEST_DEFINE(cache_filter)
 {
 	RAII_VAR(struct stasis_message_type *, non_cache_type, NULL, ao2_cleanup);
-	RAII_VAR(struct stasis_topic *, topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_topic *, topic, NULL, stasis_topic_release);
 	RAII_VAR(struct stasis_cache *, cache, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_caching_topic *, caching_topic, NULL, stasis_caching_unsubscribe);
 	RAII_VAR(struct consumer *, consumer, NULL, ao2_cleanup);
@@ -1033,7 +1033,7 @@
 AST_TEST_DEFINE(cache)
 {
 	RAII_VAR(struct stasis_message_type *, cache_type, NULL, ao2_cleanup);
-	RAII_VAR(struct stasis_topic *, topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_topic *, topic, NULL, stasis_topic_release);
 	RAII_VAR(struct stasis_cache *, cache, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_caching_topic *, caching_topic, NULL, stasis_caching_unsubscribe);
 	RAII_VAR(struct consumer *, consumer, NULL, ao2_cleanup);
@@ -1132,7 +1132,7 @@
 AST_TEST_DEFINE(cache_dump)
 {
 	RAII_VAR(struct stasis_message_type *, cache_type, NULL, ao2_cleanup);
-	RAII_VAR(struct stasis_topic *, topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_topic *, topic, NULL, stasis_topic_release);
 	RAII_VAR(struct stasis_cache *, cache, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_caching_topic *, caching_topic, NULL, stasis_caching_unsubscribe);
 	RAII_VAR(struct consumer *, consumer, NULL, ao2_cleanup);
@@ -1245,7 +1245,7 @@
 AST_TEST_DEFINE(cache_eid_aggregate)
 {
 	RAII_VAR(struct stasis_message_type *, cache_type, NULL, ao2_cleanup);
-	RAII_VAR(struct stasis_topic *, topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_topic *, topic, NULL, stasis_topic_release);
 	RAII_VAR(struct stasis_cache *, cache, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_caching_topic *, caching_topic, NULL, stasis_caching_unsubscribe);
 	RAII_VAR(struct consumer *, cache_consumer, NULL, ao2_cleanup);
@@ -1504,7 +1504,7 @@
 
 AST_TEST_DEFINE(router)
 {
-	RAII_VAR(struct stasis_topic *, topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_topic *, topic, NULL, stasis_topic_release);
 	RAII_VAR(struct stasis_message_router *, uut, NULL, stasis_message_router_unsubscribe_and_join);
 	RAII_VAR(char *, test_data, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_message_type *, test_message_type1, NULL, ao2_cleanup);
@@ -1600,7 +1600,7 @@
 
 AST_TEST_DEFINE(router_pool)
 {
-	RAII_VAR(struct stasis_topic *, topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_topic *, topic, NULL, stasis_topic_release);
 	RAII_VAR(struct stasis_message_router *, uut, NULL, stasis_message_router_unsubscribe_and_join);
 	RAII_VAR(char *, test_data, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_message_type *, test_message_type1, NULL, ao2_cleanup);
@@ -1709,7 +1709,7 @@
 
 AST_TEST_DEFINE(router_cache_updates)
 {
-	RAII_VAR(struct stasis_topic *, topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_topic *, topic, NULL, stasis_topic_release);
 	RAII_VAR(struct stasis_cache *, cache, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_caching_topic *, caching_topic, NULL, stasis_caching_unsubscribe_and_join);
 	RAII_VAR(struct stasis_message_type *, test_message_type1, NULL, ao2_cleanup);
@@ -1967,7 +1967,7 @@
 
 AST_TEST_DEFINE(dtor_order)
 {
-	RAII_VAR(struct stasis_topic *, topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_topic *, topic, NULL, stasis_topic_release);
 	RAII_VAR(struct stasis_subscription *, sub, NULL, stasis_unsubscribe);
 
 	switch (cmd) {
@@ -2005,7 +2005,7 @@
 
 AST_TEST_DEFINE(caching_dtor_order)
 {
-	RAII_VAR(struct stasis_topic *, topic, NULL, ao2_cleanup);
+	RAII_VAR(struct stasis_topic *, topic, NULL, stasis_topic_release);
 	RAII_VAR(struct stasis_cache *, cache, NULL, ao2_cleanup);
 	RAII_VAR(struct stasis_caching_topic *, caching_topic, NULL,
 		stasis_caching_unsubscribe);
@@ -2147,7 +2147,7 @@
 	struct cts *c = obj;
 
 	stasis_unsubscribe(c->sub);
-	ao2_cleanup(c->topic);
+	stasis_topic_release(c->topic);
 	ao2_cleanup(c->consumer);
 }
 

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie86d125d2966f93de74ee00f47ae6fbc8c081c5f
Gerrit-Change-Number: 10929
Gerrit-PatchSet: 1
Gerrit-Owner: sungtae kim <pchero21 at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190126/9d7c4393/attachment-0001.html>


More information about the asterisk-code-review mailing list