Skip to content

Commit bc279d1

Browse files
committed
lock the Disjoint Pool bucket before printing its stats
1 parent c80d2b2 commit bc279d1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/pool/pool_disjoint.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,9 @@ static void disjoint_pool_print_stats(disjoint_pool_t *pool) {
492492

493493
for (size_t i = 0; i < pool->buckets_num; i++) {
494494
bucket_t *bucket = pool->buckets[i];
495+
// lock bucket before accessing its stats
496+
utils_mutex_lock(&bucket->bucket_lock);
497+
495498
if (bucket->alloc_count) {
496499
LOG_DEBUG("%14zu %12zu %12zu %18zu %20zu %21zu", bucket->size,
497500
bucket->alloc_count, bucket->free_count,
@@ -500,8 +503,11 @@ static void disjoint_pool_print_stats(disjoint_pool_t *pool) {
500503
high_bucket_size =
501504
utils_max(bucket_slab_alloc_size(bucket), high_bucket_size);
502505
}
506+
503507
high_peak_slabs_in_use =
504508
utils_max(bucket->max_slabs_in_use, high_peak_slabs_in_use);
509+
510+
utils_mutex_unlock(&bucket->bucket_lock);
505511
}
506512

507513
LOG_DEBUG("current pool size: %zu",

0 commit comments

Comments
 (0)