mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
stasis_cache: Remove silly usage of RAII_VAR.
Change-Id: Ifa95e5801c949df296c7e4376347730fb0ed52ef
This commit is contained in:
@@ -868,9 +868,8 @@ static void caching_topic_exec(void *data, struct stasis_subscription *sub,
|
||||
|
||||
struct stasis_caching_topic *stasis_caching_topic_create(struct stasis_topic *original_topic, struct stasis_cache *cache)
|
||||
{
|
||||
RAII_VAR(struct stasis_caching_topic *, caching_topic, NULL, ao2_cleanup);
|
||||
struct stasis_subscription *sub;
|
||||
RAII_VAR(char *, new_name, NULL, ast_free);
|
||||
struct stasis_caching_topic *caching_topic;
|
||||
char *new_name;
|
||||
int ret;
|
||||
|
||||
ret = ast_asprintf(&new_name, "%s-cached", stasis_topic_name(original_topic));
|
||||
@@ -881,29 +880,32 @@ struct stasis_caching_topic *stasis_caching_topic_create(struct stasis_topic *or
|
||||
caching_topic = ao2_alloc_options(sizeof(*caching_topic),
|
||||
stasis_caching_topic_dtor, AO2_ALLOC_OPT_LOCK_NOLOCK);
|
||||
if (caching_topic == NULL) {
|
||||
ast_free(new_name);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
caching_topic->topic = stasis_topic_create(new_name);
|
||||
ast_free(new_name);
|
||||
if (caching_topic->topic == NULL) {
|
||||
ao2_ref(caching_topic, -1);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ao2_ref(cache, +1);
|
||||
caching_topic->cache = cache;
|
||||
|
||||
sub = internal_stasis_subscribe(original_topic, caching_topic_exec, caching_topic, 0, 0);
|
||||
if (sub == NULL) {
|
||||
caching_topic->sub = internal_stasis_subscribe(original_topic, caching_topic_exec, caching_topic, 0, 0);
|
||||
if (caching_topic->sub == NULL) {
|
||||
ao2_ref(caching_topic, -1);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ao2_ref(original_topic, +1);
|
||||
caching_topic->original_topic = original_topic;
|
||||
|
||||
/* This is for the reference contained in the subscription above */
|
||||
ao2_ref(caching_topic, +1);
|
||||
caching_topic->sub = sub;
|
||||
|
||||
/* The subscription holds the reference, so no additional ref bump. */
|
||||
return caching_topic;
|
||||
}
|
||||
|
Reference in New Issue
Block a user