From: Francis Deslauriers Date: Fri, 26 Mar 2021 18:41:01 +0000 (-0400) Subject: Fix: common: index_allocator_get_index_count() returns size X-Git-Tag: v2.13.0-rc1~181 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=5e09ab50830dd62fd39fc47f369dd484279f760a;ds=sidebyside Fix: common: index_allocator_get_index_count() returns size The lttng_index_allocator_get_index_count() should return the number of allocated indexes. Right now it returns the maximum number of indexes. I witnessed the following message when running testing the event notifier error counter feature: Warning: Destroying index allocator with 4096 slot indexes still in use Signed-off-by: Francis Deslauriers Signed-off-by: Jérémie Galarneau Change-Id: Ibbcb3f128553df0a4118901ef85ae6fe17ebcecf --- diff --git a/src/common/index-allocator.c b/src/common/index-allocator.c index 3de09a831..885015d77 100644 --- a/src/common/index-allocator.c +++ b/src/common/index-allocator.c @@ -20,6 +20,7 @@ struct lttng_index_allocator { struct cds_list_head unused_list; uint64_t size; uint64_t position; + uint64_t nb_allocated_indexes; }; struct lttng_index { @@ -40,6 +41,7 @@ struct lttng_index_allocator *lttng_index_allocator_create( allocator->size = index_count; allocator->position = 0; + allocator->nb_allocated_indexes = 0; CDS_INIT_LIST_HEAD(&allocator->unused_list); @@ -49,7 +51,7 @@ end: uint64_t lttng_index_allocator_get_index_count(struct lttng_index_allocator *allocator) { - return allocator->size; + return allocator->nb_allocated_indexes; } enum lttng_index_allocator_status lttng_index_allocator_alloc( @@ -77,6 +79,7 @@ enum lttng_index_allocator_status lttng_index_allocator_alloc( free(index); } + allocator->nb_allocated_indexes++; end: return status; } @@ -99,6 +102,7 @@ enum lttng_index_allocator_status lttng_index_allocator_release( index->index = idx; cds_list_add_tail(&index->head, &allocator->unused_list); + allocator->nb_allocated_indexes--; end: return status;