From fd7814ddb593ec628819e95fab0052d78bc6017b Mon Sep 17 00:00:00 2001
From: Corey Farrell <git@cfware.com>
Date: Fri, 18 Jul 2014 19:55:24 +0000
Subject: [PATCH] stasis: use ao2_t_alloc for certain object allocators

Add tags to stasis objects using the name.  This makes it
easier to track the source of certain stasis ref leaks.

Review: https://reviewboard.asterisk.org/r/3821/
........

Merged revisions 418996 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@418997 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 main/stasis.c                | 4 ++--
 main/stasis_cache_pattern.c  | 4 ++--
 main/stasis_message.c        | 6 +++---
 main/stasis_message_router.c | 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/main/stasis.c b/main/stasis.c
index a451e7b134..594ec5e99c 100644
--- a/main/stasis.c
+++ b/main/stasis.c
@@ -204,7 +204,7 @@ struct stasis_topic *stasis_topic_create(const char *name)
 	struct stasis_topic *topic;
 	int res = 0;
 
-	topic = ao2_alloc(sizeof(*topic), topic_dtor);
+	topic = ao2_t_alloc(sizeof(*topic), topic_dtor, name);
 	if (!topic) {
 		return NULL;
 	}
@@ -311,7 +311,7 @@ struct stasis_subscription *internal_stasis_subscribe(
 	}
 
 	/* The ao2 lock is used for join_cond. */
-	sub = ao2_alloc(sizeof(*sub), subscription_dtor);
+	sub = ao2_t_alloc(sizeof(*sub), subscription_dtor, topic->name);
 	if (!sub) {
 		return NULL;
 	}
diff --git a/main/stasis_cache_pattern.c b/main/stasis_cache_pattern.c
index 9644028c36..9e3de367ad 100644
--- a/main/stasis_cache_pattern.c
+++ b/main/stasis_cache_pattern.c
@@ -70,7 +70,7 @@ struct stasis_cp_all *stasis_cp_all_create(const char *name,
 	RAII_VAR(char *, cached_name, NULL, ast_free);
 	RAII_VAR(struct stasis_cp_all *, all, NULL, ao2_cleanup);
 
-	all = ao2_alloc(sizeof(*all), all_dtor);
+	all = ao2_t_alloc(sizeof(*all), all_dtor, name);
 	if (!all) {
 		return NULL;
 	}
@@ -138,7 +138,7 @@ struct stasis_cp_single *stasis_cp_single_create(struct stasis_cp_all *all,
 {
 	RAII_VAR(struct stasis_cp_single *, one, NULL, ao2_cleanup);
 
-	one = ao2_alloc(sizeof(*one), one_dtor);
+	one = ao2_t_alloc(sizeof(*one), one_dtor, name);
 	if (!one) {
 		return NULL;
 	}
diff --git a/main/stasis_message.c b/main/stasis_message.c
index 6132efc20d..70c4085390 100644
--- a/main/stasis_message.c
+++ b/main/stasis_message.c
@@ -55,7 +55,7 @@ struct stasis_message_type *stasis_message_type_create(const char *name,
 {
 	struct stasis_message_type *type;
 
-	type = ao2_alloc(sizeof(*type), message_type_dtor);
+	type = ao2_t_alloc(sizeof(*type), message_type_dtor, name);
 	if (!type) {
 		return NULL;
 	}
@@ -108,7 +108,7 @@ struct stasis_message *stasis_message_create_full(struct stasis_message_type *ty
 		return NULL;
 	}
 
-	message = ao2_alloc(sizeof(*message), stasis_message_dtor);
+	message = ao2_t_alloc(sizeof(*message), stasis_message_dtor, type->name);
 	if (message == NULL) {
 		return NULL;
 	}
@@ -191,4 +191,4 @@ struct ast_json *stasis_message_to_json(
 struct ast_event *stasis_message_to_event(struct stasis_message *msg)
 {
 	return INVOKE_VIRTUAL(to_event, msg);
-}
\ No newline at end of file
+}
diff --git a/main/stasis_message_router.c b/main/stasis_message_router.c
index 41495db11f..900265e6c1 100644
--- a/main/stasis_message_router.c
+++ b/main/stasis_message_router.c
@@ -212,7 +212,7 @@ struct stasis_message_router *stasis_message_router_create(
 	int res;
 	RAII_VAR(struct stasis_message_router *, router, NULL, ao2_cleanup);
 
-	router = ao2_alloc(sizeof(*router), router_dtor);
+	router = ao2_t_alloc(sizeof(*router), router_dtor, topic->name);
 	if (!router) {
 		return NULL;
 	}
-- 
GitLab