[block-cache] fix leaking validators
The memory for the blocks is explicitly managed, and the destructors for the blocks wasn't being called.
This commit is contained in:
parent
0d3942cae8
commit
4799becb01
@ -77,6 +77,21 @@ block_cache::init_free_list(unsigned count)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
block_cache::exit_free_list()
|
||||||
|
{
|
||||||
|
if (blocks_data_)
|
||||||
|
free(blocks_data_);
|
||||||
|
|
||||||
|
if (blocks_memory_) {
|
||||||
|
struct block *blocks = static_cast<block *>(blocks_memory_);
|
||||||
|
for (unsigned i = 0; i < nr_cache_blocks_; i++)
|
||||||
|
(blocks + i)->~block();
|
||||||
|
|
||||||
|
free(blocks_memory_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
block_cache::block *
|
block_cache::block *
|
||||||
block_cache::__alloc_block()
|
block_cache::__alloc_block()
|
||||||
{
|
{
|
||||||
@ -475,11 +490,7 @@ block_cache::~block_cache()
|
|||||||
flush();
|
flush();
|
||||||
wait_all();
|
wait_all();
|
||||||
|
|
||||||
if (blocks_memory_)
|
exit_free_list();
|
||||||
free(blocks_memory_);
|
|
||||||
|
|
||||||
if (blocks_data_)
|
|
||||||
free(blocks_data_);
|
|
||||||
|
|
||||||
if (aio_context_)
|
if (aio_context_)
|
||||||
io_destroy(aio_context_);
|
io_destroy(aio_context_);
|
||||||
|
@ -138,6 +138,7 @@ namespace bcache {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int init_free_list(unsigned count);
|
int init_free_list(unsigned count);
|
||||||
|
void exit_free_list();
|
||||||
block *__alloc_block();
|
block *__alloc_block();
|
||||||
void complete_io(block &b, int result);
|
void complete_io(block &b, int result);
|
||||||
void issue_low_level(block &b, enum io_iocb_cmd opcode, const char *desc);
|
void issue_low_level(block &b, enum io_iocb_cmd opcode, const char *desc);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user