* 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
This commit is contained in:
Axel Dörfler
2005-12-16 15:45:00 +00:00
parent 005108a262
commit 182f88dda1
2 changed files with 5 additions and 6 deletions
+5 -5
View File
@@ -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;
-1
View File
@@ -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;