From 47f23fb5c19d8c7a2d2adfa7ea48e8a1d3557c80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 10 Mar 2010 10:57:37 +0000 Subject: [PATCH] * If get_cached_block() failed reading a block, it would leave a deleted object in the unused list if it got the block via block_cache::_GetUnusedBlock(). * block_cache::_GetUnusedBlock() leaked the compare data block if the BLOCK_CACHE_DEBUG_CHANGED feature had been enabled. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35799 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/cache/block_cache.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/system/kernel/cache/block_cache.cpp b/src/system/kernel/cache/block_cache.cpp index 5d5cfeee6a..131ff54417 100644 --- a/src/system/kernel/cache/block_cache.cpp +++ b/src/system/kernel/cache/block_cache.cpp @@ -1586,6 +1586,10 @@ block_cache::_GetUnusedBlock() if (block->original_data != NULL) Free(block->original_data); +#if BLOCK_CACHE_DEBUG_CHANGED + if (block->compare != NULL) + Free(block->compare); +#endif return block; } @@ -1809,6 +1813,12 @@ retry: goto retry; } + if (block->unused) { + //TRACE(("remove block %Ld from unused\n", blockNumber)); + block->unused = false; + cache->unused_blocks.Remove(block); + } + if (*_allocated && readBlock) { // read block into cache int32 blockSize = cache->block_size; @@ -1833,12 +1843,6 @@ retry: mark_block_unbusy_reading(cache, block); } - if (block->unused) { - //TRACE(("remove block %Ld from unused\n", blockNumber)); - block->unused = false; - cache->unused_blocks.Remove(block); - } - block->ref_count++; block->last_accessed = system_time() / 1000000L;