[haiku-commits] r35648 - haiku/trunk/src/system/kernel/cache

  • From: mmlr@xxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 28 Feb 2010 01:02:31 +0100 (CET)

Author: mmlr
Date: 2010-02-28 01:02:31 +0100 (Sun, 28 Feb 2010)
New Revision: 35648
Changeset: http://dev.haiku-os.org/changeset/35648/haiku

Modified:
   haiku/trunk/src/system/kernel/cache/block_cache.cpp
Log:
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.


Modified: haiku/trunk/src/system/kernel/cache/block_cache.cpp
===================================================================
--- haiku/trunk/src/system/kernel/cache/block_cache.cpp 2010-02-27 23:19:13 UTC 
(rev 35647)
+++ haiku/trunk/src/system/kernel/cache/block_cache.cpp 2010-02-28 00:02:31 UTC 
(rev 35648)
@@ -1834,6 +1834,8 @@
 
                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 @@
                }
                TB(Read(cache, block));
 
-               mutex_lock(&cache->lock);
                mark_block_unbusy_reading(cache, block);
        }
 


Other related posts:

  • » [haiku-commits] r35648 - haiku/trunk/src/system/kernel/cache - mmlr