From e7385fa68ef1818324cd935a6b4131824fc95d17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sun, 3 Jan 2010 19:08:40 +0000 Subject: [PATCH] * If a block allocation fails, remove an unused one and try again - this might improve the reliability as long as our slab implementation is a PITA. * Removed an assertion that will no longer work (due to the DoublyLinkedList changes). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34877 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/cache/block_cache.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/system/kernel/cache/block_cache.cpp b/src/system/kernel/cache/block_cache.cpp index 5bcd84f44c..f5c006c7a6 100644 --- a/src/system/kernel/cache/block_cache.cpp +++ b/src/system/kernel/cache/block_cache.cpp @@ -1000,6 +1000,13 @@ block_cache::Allocate() RemoveUnusedBlocks(1, 2); } + void* block = object_cache_alloc(buffer_cache, 0); + if (block != NULL) + return block; + + // recycle existing before allocating a new one + RemoveUnusedBlocks(1, 2); + return object_cache_alloc(buffer_cache, 0); } @@ -1332,9 +1339,9 @@ retry: // The block is currently busy - wait and try again later ConditionVariableEntry entry; cache->busy_condition.Add(&entry); - + mutex_unlock(&cache->lock); - + entry.Wait(); mutex_lock(&cache->lock); @@ -2125,10 +2132,6 @@ wait_for_notifications(block_cache* cache) // wait for notification hook to be called entry.Wait(); - - ASSERT(notification.GetDoublyLinkedListLink()->next == NULL - && notification.GetDoublyLinkedListLink()->previous == NULL - && cache->pending_notifications.Head() != ¬ification); } @@ -2782,7 +2785,7 @@ block_cache_delete(void* _cache, bool allowWrites) cache->busy_condition.Add(&entry); mutex_unlock(&cache->lock); - + entry.Wait(); mutex_lock(&cache->lock);