Fixed broken iteration in block_cache::RemoveUnusedBlocks(). The loop
would start with the first block in the unused blocks list, but then continue with the blocks that share the same hash table slot, thus freeing potentially used blocks. Could theoretically have caused BFS to see and write incorrect meta/administrative data on certain occasions. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20459 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
2e474644c7
commit
3e414ec314
8
src/system/kernel/cache/block_cache.cpp
vendored
8
src/system/kernel/cache/block_cache.cpp
vendored
@ -339,10 +339,8 @@ block_cache::RemoveUnusedBlocks(int32 maxAccessed, int32 count)
|
||||
{
|
||||
TRACE(("block_cache: remove up to %ld unused blocks\n", count));
|
||||
|
||||
cached_block *next = NULL;
|
||||
for (cached_block *block = unused_blocks.First(); block != NULL;
|
||||
block = next) {
|
||||
next = block->next;
|
||||
for (block_list::Iterator it = unused_blocks.GetIterator();
|
||||
cached_block *block = it.Next();) {
|
||||
|
||||
if (maxAccessed < block->accessed)
|
||||
continue;
|
||||
@ -355,7 +353,7 @@ block_cache::RemoveUnusedBlocks(int32 maxAccessed, int32 count)
|
||||
write_cached_block(this, block, false);
|
||||
|
||||
// remove block from lists
|
||||
unused_blocks.Remove(block);
|
||||
it.Remove();
|
||||
hash_remove(hash, block);
|
||||
|
||||
FreeBlock(block);
|
||||
|
Loading…
Reference in New Issue
Block a user