From 182f88dda1eb7a10964f09863deebe13b68241da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 16 Dec 2005 15:45:00 +0000 Subject: [PATCH] * block_cache_delete() now deletes the cache with with its lock held. * the link were not initialized in cached_block, as its constructor were never called (was using malloc/free instead of new/delete). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15564 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/cache/block_cache.cpp | 10 +++++----- src/system/kernel/cache/block_cache_private.h | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/system/kernel/cache/block_cache.cpp b/src/system/kernel/cache/block_cache.cpp index f3fd555a29..e8d8e450aa 100644 --- a/src/system/kernel/cache/block_cache.cpp +++ b/src/system/kernel/cache/block_cache.cpp @@ -275,20 +275,20 @@ block_cache::FreeBlock(cached_block *block) if (range->Unused(this)) block_range::Delete(this, range); - free(block); + delete block; } cached_block * block_cache::NewBlock(off_t blockNumber) { - cached_block *block = (cached_block *)malloc(sizeof(cached_block)); + cached_block *block = new cached_block; if (block == NULL) return NULL; block_range *range = GetFreeRange(); if (range == NULL) { - free(block); + delete block; return NULL; } @@ -322,8 +322,6 @@ block_cache::RemoveUnusedBlocks(int32 maxAccessed, int32 count) for (cached_block *block = unused_blocks.First(); block != NULL; block = next) { next = block->next; - if (block == NULL) - break; if (maxAccessed < block->accessed) continue; @@ -1039,6 +1037,8 @@ block_cache_delete(void *_cache, bool allowWrites) if (allowWrites) block_cache_sync(cache); + BenaphoreLocker locker(&cache->lock); + // free all blocks uint32 cookie = 0; diff --git a/src/system/kernel/cache/block_cache_private.h b/src/system/kernel/cache/block_cache_private.h index f1840314fa..965806044f 100644 --- a/src/system/kernel/cache/block_cache_private.h +++ b/src/system/kernel/cache/block_cache_private.h @@ -33,7 +33,6 @@ struct cached_block { cached_block *transaction_next; block_link link; cached_block *chunk_next; - block_chunk *chunk; off_t block_number; void *data; void *original;