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

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 10 Mar 2010 11:57:37 +0100 (CET)

Author: axeld
Date: 2010-03-10 11:57:37 +0100 (Wed, 10 Mar 2010)
New Revision: 35799
Changeset: http://dev.haiku-os.org/changeset/35799/haiku

Modified:
   haiku/trunk/src/system/kernel/cache/block_cache.cpp
Log:
* If get_cached_block() failed reading a block, it would leave a deleted object
  in the unused list if it got the block via block_cache::_GetUnusedBlock().
* block_cache::_GetUnusedBlock() leaked the compare data block if the
  BLOCK_CACHE_DEBUG_CHANGED feature had been enabled.


Modified: haiku/trunk/src/system/kernel/cache/block_cache.cpp
===================================================================
--- haiku/trunk/src/system/kernel/cache/block_cache.cpp 2010-03-10 06:34:45 UTC 
(rev 35798)
+++ haiku/trunk/src/system/kernel/cache/block_cache.cpp 2010-03-10 10:57:37 UTC 
(rev 35799)
@@ -1586,6 +1586,10 @@
                if (block->original_data != NULL)
                        Free(block->original_data);
 
+#if BLOCK_CACHE_DEBUG_CHANGED
+               if (block->compare != NULL)
+                       Free(block->compare);
+#endif
                return block;
        }
 
@@ -1809,6 +1813,12 @@
                goto retry;
        }
 
+       if (block->unused) {
+               //TRACE(("remove block %Ld from unused\n", blockNumber));
+               block->unused = false;
+               cache->unused_blocks.Remove(block);
+       }
+
        if (*_allocated && readBlock) {
                // read block into cache
                int32 blockSize = cache->block_size;
@@ -1833,12 +1843,6 @@
                mark_block_unbusy_reading(cache, block);
        }
 
-       if (block->unused) {
-               //TRACE(("remove block %Ld from unused\n", blockNumber));
-               block->unused = false;
-               cache->unused_blocks.Remove(block);
-       }
-
        block->ref_count++;
        block->last_accessed = system_time() / 1000000L;
 


Other related posts:

  • » [haiku-commits] r35799 - haiku/trunk/src/system/kernel/cache - axeld