* 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:
+5
-5
@@ -275,20 +275,20 @@ block_cache::FreeBlock(cached_block *block)
|
|||||||
if (range->Unused(this))
|
if (range->Unused(this))
|
||||||
block_range::Delete(this, range);
|
block_range::Delete(this, range);
|
||||||
|
|
||||||
free(block);
|
delete block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cached_block *
|
cached_block *
|
||||||
block_cache::NewBlock(off_t blockNumber)
|
block_cache::NewBlock(off_t blockNumber)
|
||||||
{
|
{
|
||||||
cached_block *block = (cached_block *)malloc(sizeof(cached_block));
|
cached_block *block = new cached_block;
|
||||||
if (block == NULL)
|
if (block == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
block_range *range = GetFreeRange();
|
block_range *range = GetFreeRange();
|
||||||
if (range == NULL) {
|
if (range == NULL) {
|
||||||
free(block);
|
delete block;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,8 +322,6 @@ block_cache::RemoveUnusedBlocks(int32 maxAccessed, int32 count)
|
|||||||
for (cached_block *block = unused_blocks.First(); block != NULL; block = next) {
|
for (cached_block *block = unused_blocks.First(); block != NULL; block = next) {
|
||||||
next = block->next;
|
next = block->next;
|
||||||
|
|
||||||
if (block == NULL)
|
|
||||||
break;
|
|
||||||
if (maxAccessed < block->accessed)
|
if (maxAccessed < block->accessed)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -1039,6 +1037,8 @@ block_cache_delete(void *_cache, bool allowWrites)
|
|||||||
if (allowWrites)
|
if (allowWrites)
|
||||||
block_cache_sync(cache);
|
block_cache_sync(cache);
|
||||||
|
|
||||||
|
BenaphoreLocker locker(&cache->lock);
|
||||||
|
|
||||||
// free all blocks
|
// free all blocks
|
||||||
|
|
||||||
uint32 cookie = 0;
|
uint32 cookie = 0;
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ struct cached_block {
|
|||||||
cached_block *transaction_next;
|
cached_block *transaction_next;
|
||||||
block_link link;
|
block_link link;
|
||||||
cached_block *chunk_next;
|
cached_block *chunk_next;
|
||||||
block_chunk *chunk;
|
|
||||||
off_t block_number;
|
off_t block_number;
|
||||||
void *data;
|
void *data;
|
||||||
void *original;
|
void *original;
|
||||||
|
|||||||
Reference in New Issue
Block a user