<p>Friendly Automation <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/11304">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">stasis: Fix crash at shutdown.<br><br>When compiling in dev mode, stasis statistics are enabled and can cause<br>a crash at shutdown due to the following:<br>- Containers are freed<br>- Topics and subscriptions remain<br>- When those topics and subscriptions are deallocated, they go to do<br> things with the container<br><br>This changes the containers to global ao2 objects, and whenever needed<br>in the code, a reference must be obtained and checked before any<br>operations can be done.<br><br>ASTERISK-28353 #close<br><br>Change-Id: Ie7d5e907fcfcb4d65bd36d5e4eb923126fde8d33<br>---<br>M main/stasis.c<br>1 file changed, 111 insertions(+), 20 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/stasis.c b/main/stasis.c</span><br><span>index 3fee6ba..8cbfe724 100644</span><br><span>--- a/main/stasis.c</span><br><span>+++ b/main/stasis.c</span><br><span>@@ -317,11 +317,11 @@</span><br><span> /*! The number of buckets to use for subscription statistics */</span><br><span> #define SUBSCRIPTION_STATISTICS_BUCKETS 57</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/*! Container which stores statistics for topics */</span><br><span style="color: hsl(0, 100%, 40%);">-static struct ao2_container *topic_statistics;</span><br><span style="color: hsl(120, 100%, 40%);">+/*! Global container which stores statistics for topics */</span><br><span style="color: hsl(120, 100%, 40%);">+static AO2_GLOBAL_OBJ_STATIC(topic_statistics);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/*! Container which stores statistics for subscriptions */</span><br><span style="color: hsl(0, 100%, 40%);">-static struct ao2_container *subscription_statistics;</span><br><span style="color: hsl(120, 100%, 40%);">+/*! Global container which stores statistics for subscriptions */</span><br><span style="color: hsl(120, 100%, 40%);">+static AO2_GLOBAL_OBJ_STATIC(subscription_statistics);</span><br><span> </span><br><span> /*! \internal */</span><br><span> struct stasis_message_type_statistics {</span><br><span>@@ -395,6 +395,9 @@</span><br><span> static void topic_dtor(void *obj)</span><br><span> {</span><br><span> struct stasis_topic *topic = obj;</span><br><span style="color: hsl(120, 100%, 40%);">+#ifdef AST_DEVMODE</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ao2_container *topic_stats;</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span> </span><br><span> /* Subscribers hold a reference to topics, so they should all be</span><br><span> * unsubscribed before we get here. */</span><br><span>@@ -406,7 +409,11 @@</span><br><span> </span><br><span> #ifdef AST_DEVMODE</span><br><span> if (topic->statistics) {</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_unlink(topic_statistics, topic->statistics);</span><br><span style="color: hsl(120, 100%, 40%);">+ topic_stats = ao2_global_obj_ref(topic_statistics);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (topic_stats) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_unlink(topic_stats, topic->statistics);</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(topic_stats, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> ao2_ref(topic->statistics, -1);</span><br><span> }</span><br><span> #endif</span><br><span>@@ -423,6 +430,11 @@</span><br><span> static struct stasis_topic_statistics *stasis_topic_statistics_create(struct stasis_topic *topic)</span><br><span> {</span><br><span> struct stasis_topic_statistics *statistics;</span><br><span style="color: hsl(120, 100%, 40%);">+ RAII_VAR(struct ao2_container *, topic_stats, ao2_global_obj_ref(topic_statistics), ao2_cleanup);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!topic_stats) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> </span><br><span> statistics = ao2_alloc(sizeof(*statistics) + strlen(topic->name) + 1, topic_statistics_destroy);</span><br><span> if (!statistics) {</span><br><span>@@ -438,7 +450,7 @@</span><br><span> /* This is strictly used for the pointer address when showing the topic */</span><br><span> statistics->topic = topic;</span><br><span> strcpy(statistics->name, topic->name); /* SAFE */</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_link(topic_statistics, statistics);</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_link(topic_stats, statistics);</span><br><span> </span><br><span> return statistics;</span><br><span> }</span><br><span>@@ -552,6 +564,9 @@</span><br><span> static void subscription_dtor(void *obj)</span><br><span> {</span><br><span> struct stasis_subscription *sub = obj;</span><br><span style="color: hsl(120, 100%, 40%);">+#ifdef AST_DEVMODE</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ao2_container *subscription_stats;</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span> </span><br><span> /* Subscriptions need to be manually unsubscribed before destruction</span><br><span> * b/c there's a cyclic reference between topics and subscriptions */</span><br><span>@@ -571,7 +586,11 @@</span><br><span> </span><br><span> #ifdef AST_DEVMODE</span><br><span> if (sub->statistics) {</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_unlink(subscription_statistics, sub->statistics);</span><br><span style="color: hsl(120, 100%, 40%);">+ subscription_stats = ao2_global_obj_ref(subscription_statistics);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (subscription_stats) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_unlink(subscription_stats, sub->statistics);</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(subscription_stats, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> ao2_ref(sub->statistics, -1);</span><br><span> }</span><br><span> #endif</span><br><span>@@ -655,6 +674,11 @@</span><br><span> const char *func)</span><br><span> {</span><br><span> struct stasis_subscription_statistics *statistics;</span><br><span style="color: hsl(120, 100%, 40%);">+ RAII_VAR(struct ao2_container *, subscription_stats, ao2_global_obj_ref(subscription_statistics), ao2_cleanup);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!subscription_stats) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> </span><br><span> statistics = ao2_alloc(sizeof(*statistics) + strlen(sub->uniqueid) + 1, subscription_statistics_destroy);</span><br><span> if (!statistics) {</span><br><span>@@ -674,7 +698,7 @@</span><br><span> statistics->uses_threadpool = use_thread_pool;</span><br><span> strcpy(statistics->uniqueid, sub->uniqueid); /* SAFE */</span><br><span> statistics->sub = sub;</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_link(subscription_statistics, statistics);</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_link(subscription_stats, statistics);</span><br><span> </span><br><span> return statistics;</span><br><span> }</span><br><span>@@ -2147,6 +2171,7 @@</span><br><span> static char *statistics_show_subscriptions(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)</span><br><span> {</span><br><span> struct ao2_container *sorted_subscriptions;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ao2_container *subscription_stats;</span><br><span> struct ao2_iterator iter;</span><br><span> struct stasis_subscription_statistics *statistics;</span><br><span> int count = 0;</span><br><span>@@ -2171,19 +2196,29 @@</span><br><span> return CLI_SHOWUSAGE;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ subscription_stats = ao2_global_obj_ref(subscription_statistics);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!subscription_stats) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_cli(a->fd, "Could not fetch subscription_statistics container\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ return CLI_FAILURE;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> sorted_subscriptions = ao2_container_alloc_rbtree(AO2_ALLOC_OPT_LOCK_NOLOCK, 0,</span><br><span> stasis_subscription_statistics_sort_fn, NULL);</span><br><span> if (!sorted_subscriptions) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(subscription_stats, -1);</span><br><span> ast_cli(a->fd, "Could not create container for sorting subscription statistics\n");</span><br><span> return CLI_SUCCESS;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (ao2_container_dup(sorted_subscriptions, subscription_statistics, 0)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ao2_container_dup(sorted_subscriptions, subscription_stats, 0)) {</span><br><span> ao2_ref(sorted_subscriptions, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(subscription_stats, -1);</span><br><span> ast_cli(a->fd, "Could not sort subscription statistics\n");</span><br><span> return CLI_SUCCESS;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(subscription_stats, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ast_cli(a->fd, "\n" FMT_HEADERS, "Subscription", "Dropped", "Passed", "Lowest Invoke", "Highest Invoke");</span><br><span> </span><br><span> iter = ao2_iterator_init(sorted_subscriptions, 0);</span><br><span>@@ -2216,12 +2251,18 @@</span><br><span> static char *subscription_statistics_complete_name(const char *word, int state)</span><br><span> {</span><br><span> struct stasis_subscription_statistics *statistics;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ao2_container *subscription_stats;</span><br><span> struct ao2_iterator it_statistics;</span><br><span> int wordlen = strlen(word);</span><br><span> int which = 0;</span><br><span> char *result = NULL;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- it_statistics = ao2_iterator_init(subscription_statistics, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ subscription_stats = ao2_global_obj_ref(subscription_statistics);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!subscription_stats) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return result;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ it_statistics = ao2_iterator_init(subscription_stats, 0);</span><br><span> while ((statistics = ao2_iterator_next(&it_statistics))) {</span><br><span> if (!strncasecmp(word, statistics->uniqueid, wordlen)</span><br><span> && ++which > state) {</span><br><span>@@ -2233,6 +2274,7 @@</span><br><span> }</span><br><span> }</span><br><span> ao2_iterator_destroy(&it_statistics);</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(subscription_stats, -1);</span><br><span> return result;</span><br><span> }</span><br><span> </span><br><span>@@ -2243,6 +2285,7 @@</span><br><span> static char *statistics_show_subscription(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)</span><br><span> {</span><br><span> struct stasis_subscription_statistics *statistics;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ao2_container *subscription_stats;</span><br><span> struct ao2_iterator i;</span><br><span> char *name;</span><br><span> </span><br><span>@@ -2265,12 +2308,21 @@</span><br><span> return CLI_SHOWUSAGE;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- statistics = ao2_find(subscription_statistics, a->argv[4], OBJ_SEARCH_KEY);</span><br><span style="color: hsl(120, 100%, 40%);">+ subscription_stats = ao2_global_obj_ref(subscription_statistics);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!subscription_stats) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_cli(a->fd, "Could not fetch subcription_statistics container\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ return CLI_FAILURE;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ statistics = ao2_find(subscription_stats, a->argv[4], OBJ_SEARCH_KEY);</span><br><span> if (!statistics) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(subscription_stats, -1);</span><br><span> ast_cli(a->fd, "Specified subscription '%s' does not exist\n", a->argv[4]);</span><br><span> return CLI_FAILURE;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(subscription_stats, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ast_cli(a->fd, "Subscription: %s\n", statistics->uniqueid);</span><br><span> ast_cli(a->fd, "Pointer Address: %p\n", statistics->sub);</span><br><span> ast_cli(a->fd, "Source filename: %s\n", S_OR(statistics->file, "<unavailable>"));</span><br><span>@@ -2313,6 +2365,7 @@</span><br><span> static char *statistics_show_topics(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)</span><br><span> {</span><br><span> struct ao2_container *sorted_topics;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ao2_container *topic_stats;</span><br><span> struct ao2_iterator iter;</span><br><span> struct stasis_topic_statistics *statistics;</span><br><span> int count = 0;</span><br><span>@@ -2337,19 +2390,29 @@</span><br><span> return CLI_SHOWUSAGE;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ topic_stats = ao2_global_obj_ref(topic_statistics);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!topic_stats) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_cli(a->fd, "Could not fetch topic_statistics container\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ return CLI_FAILURE;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> sorted_topics = ao2_container_alloc_rbtree(AO2_ALLOC_OPT_LOCK_NOLOCK, 0,</span><br><span> stasis_topic_statistics_sort_fn, NULL);</span><br><span> if (!sorted_topics) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(topic_stats, -1);</span><br><span> ast_cli(a->fd, "Could not create container for sorting topic statistics\n");</span><br><span> return CLI_SUCCESS;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (ao2_container_dup(sorted_topics, topic_statistics, 0)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ao2_container_dup(sorted_topics, topic_stats, 0)) {</span><br><span> ao2_ref(sorted_topics, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(topic_stats, -1);</span><br><span> ast_cli(a->fd, "Could not sort topic statistics\n");</span><br><span> return CLI_SUCCESS;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(topic_stats, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ast_cli(a->fd, "\n" FMT_HEADERS, "Topic", "Subscribers", "Dropped", "Dispatched", "Lowest Dispatch", "Highest Dispatch");</span><br><span> </span><br><span> iter = ao2_iterator_init(sorted_topics, 0);</span><br><span>@@ -2383,12 +2446,18 @@</span><br><span> static char *topic_statistics_complete_name(const char *word, int state)</span><br><span> {</span><br><span> struct stasis_topic_statistics *statistics;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ao2_container *topic_stats;</span><br><span> struct ao2_iterator it_statistics;</span><br><span> int wordlen = strlen(word);</span><br><span> int which = 0;</span><br><span> char *result = NULL;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- it_statistics = ao2_iterator_init(topic_statistics, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ topic_stats = ao2_global_obj_ref(topic_statistics);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!topic_stats) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return result;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ it_statistics = ao2_iterator_init(topic_stats, 0);</span><br><span> while ((statistics = ao2_iterator_next(&it_statistics))) {</span><br><span> if (!strncasecmp(word, statistics->name, wordlen)</span><br><span> && ++which > state) {</span><br><span>@@ -2400,6 +2469,7 @@</span><br><span> }</span><br><span> }</span><br><span> ao2_iterator_destroy(&it_statistics);</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(topic_stats, -1);</span><br><span> return result;</span><br><span> }</span><br><span> </span><br><span>@@ -2410,6 +2480,7 @@</span><br><span> static char *statistics_show_topic(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)</span><br><span> {</span><br><span> struct stasis_topic_statistics *statistics;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ao2_container *topic_stats;</span><br><span> struct ao2_iterator i;</span><br><span> char *uniqueid;</span><br><span> </span><br><span>@@ -2432,12 +2503,21 @@</span><br><span> return CLI_SHOWUSAGE;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- statistics = ao2_find(topic_statistics, a->argv[4], OBJ_SEARCH_KEY);</span><br><span style="color: hsl(120, 100%, 40%);">+ topic_stats = ao2_global_obj_ref(topic_statistics);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!topic_stats) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_cli(a->fd, "Could not fetch topic_statistics container\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ return CLI_FAILURE;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ statistics = ao2_find(topic_stats, a->argv[4], OBJ_SEARCH_KEY);</span><br><span> if (!statistics) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(topic_stats, -1);</span><br><span> ast_cli(a->fd, "Specified topic '%s' does not exist\n", a->argv[4]);</span><br><span> return CLI_FAILURE;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(topic_stats, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ast_cli(a->fd, "Topic: %s\n", statistics->name);</span><br><span> ast_cli(a->fd, "Pointer Address: %p\n", statistics->topic);</span><br><span> ast_cli(a->fd, "Number of messages published that went to no subscriber: %d\n", statistics->messages_not_dispatched);</span><br><span>@@ -2645,8 +2725,8 @@</span><br><span> #ifdef AST_DEVMODE</span><br><span> ast_cli_unregister_multiple(cli_stasis_statistics, ARRAY_LEN(cli_stasis_statistics));</span><br><span> AST_VECTOR_FREE(&message_type_statistics);</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_cleanup(subscription_statistics);</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_cleanup(topic_statistics);</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_global_obj_release(subscription_statistics);</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_global_obj_release(topic_statistics);</span><br><span> #endif</span><br><span> ast_threadpool_shutdown(pool);</span><br><span> pool = NULL;</span><br><span>@@ -2661,6 +2741,10 @@</span><br><span> struct stasis_config *cfg;</span><br><span> int cache_init;</span><br><span> struct ast_threadpool_options threadpool_opts = { 0, };</span><br><span style="color: hsl(120, 100%, 40%);">+#ifdef AST_DEVMODE</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ao2_container *subscription_stats;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ao2_container *topic_stats;</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span> </span><br><span> /* Be sure the types are cleaned up after the message bus */</span><br><span> ast_register_cleanup(stasis_cleanup);</span><br><span>@@ -2746,15 +2830,22 @@</span><br><span> /* Statistics information is stored separately so that we don't alter or interrupt the lifetime of the underlying</span><br><span> * topic or subscripton.</span><br><span> */</span><br><span style="color: hsl(0, 100%, 40%);">- subscription_statistics = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, SUBSCRIPTION_STATISTICS_BUCKETS,</span><br><span style="color: hsl(120, 100%, 40%);">+ subscription_stats = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, SUBSCRIPTION_STATISTICS_BUCKETS,</span><br><span> subscription_statistics_hash, 0, subscription_statistics_cmp);</span><br><span style="color: hsl(0, 100%, 40%);">- if (!subscription_statistics) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!subscription_stats) {</span><br><span> return -1;</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_global_obj_replace_unref(subscription_statistics, subscription_stats);</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_cleanup(subscription_stats);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- topic_statistics = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, TOPIC_STATISTICS_BUCKETS,</span><br><span style="color: hsl(120, 100%, 40%);">+ topic_stats = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, TOPIC_STATISTICS_BUCKETS,</span><br><span> topic_statistics_hash, 0, topic_statistics_cmp);</span><br><span style="color: hsl(0, 100%, 40%);">- if (!topic_statistics) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!topic_stats) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_global_obj_replace_unref(topic_statistics, topic_stats);</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_cleanup(topic_stats);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!topic_stats) {</span><br><span> return -1;</span><br><span> }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/11304">change 11304</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/11304"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-Change-Id: Ie7d5e907fcfcb4d65bd36d5e4eb923126fde8d33 </div>
<div style="display:none"> Gerrit-Change-Number: 11304 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>