From a282be40e4394c1ee7d59f3a19aa5de15fcc0a5e Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 28 Feb 2010 00:02:31 +0000 Subject: [PATCH] Re-lock the cache directly after the read. Otherwise the error case would remove the block from an unlocked cache and the cache->lock would be unlocked twice when the calling function unlocked. It panics in that case anyway, but this should make it continuable and is more correct. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35648 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/cache/block_cache.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/system/kernel/cache/block_cache.cpp b/src/system/kernel/cache/block_cache.cpp index d77c4cf4ff..3ccbda4241 100644 --- a/src/system/kernel/cache/block_cache.cpp +++ b/src/system/kernel/cache/block_cache.cpp @@ -1834,6 +1834,8 @@ retry: ssize_t bytesRead = read_pos(cache->fd, blockNumber * blockSize, block->current_data, blockSize); + + mutex_lock(&cache->lock); if (bytesRead < blockSize) { cache->RemoveBlock(block); TB(Error(cache, blockNumber, "read failed", bytesRead)); @@ -1844,7 +1846,6 @@ retry: } TB(Read(cache, block)); - mutex_lock(&cache->lock); mark_block_unbusy_reading(cache, block); }