From a73b2a26b6a91bd882eb7cd8324bf64b04709b55 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sun, 16 Mar 2025 13:43:22 +0300 Subject: [PATCH] Fix blockstore initialization after moving clean_dyn_size calc to calc_lengths --- src/blockstore/blockstore_impl.cpp | 7 ++++--- src/blockstore/blockstore_impl.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/blockstore/blockstore_impl.cpp b/src/blockstore/blockstore_impl.cpp index d8e578fe..1344ac5f 100644 --- a/src/blockstore/blockstore_impl.cpp +++ b/src/blockstore/blockstore_impl.cpp @@ -12,14 +12,14 @@ blockstore_impl_t::blockstore_impl_t(blockstore_config_t & config, ring_loop_t * ringloop->register_consumer(&ring_consumer); initialized = 0; parse_config(config, true); - zero_object = (uint8_t*)memalign_or_die(MEM_ALIGNMENT, dsk.data_block_size); - alloc_dyn_data = dsk.clean_dyn_size > sizeof(void*) || dsk.csum_block_size > 0; try { dsk.open_data(); dsk.open_meta(); dsk.open_journal(); calc_lengths(); + alloc_dyn_data = dsk.clean_dyn_size > sizeof(void*) || dsk.csum_block_size > 0; + zero_object = (uint8_t*)memalign_or_die(MEM_ALIGNMENT, dsk.data_block_size); data_alloc = new allocator_t(dsk.block_count); } catch (std::exception & e) @@ -34,7 +34,8 @@ blockstore_impl_t::~blockstore_impl_t() { delete data_alloc; delete flusher; - free(zero_object); + if (zero_object) + free(zero_object); ringloop->unregister_consumer(&ring_consumer); dsk.close_all(); if (metadata_buffer) diff --git a/src/blockstore/blockstore_impl.h b/src/blockstore/blockstore_impl.h index 0ea8ae8a..800e3f87 100644 --- a/src/blockstore/blockstore_impl.h +++ b/src/blockstore/blockstore_impl.h @@ -281,7 +281,7 @@ class blockstore_impl_t int unsynced_queued_ops = 0; allocator_t *data_alloc = NULL; uint64_t used_blocks = 0; - uint8_t *zero_object; + uint8_t *zero_object = NULL; void *metadata_buffer = NULL;