* object_cache_return_object_wrapper(): Calling object_cache_free() is a bad

idea, since that would potentially add the object back to the object store
  or lead to infinite recursion. When the object cache is destroyed it most
  likely led to infinite loops, because the object would alternately be
  removed from and added back to the object store.
* delete_object_cache(): Lock after destroying the object store, so we don't
  deadlock.
* Use the object store on SMP machines. It seems to work, though I only
  tested with the network stack and that seems to have problems of its own.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35182 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2010-01-19 20:45:20 +00:00
parent bcf73b3a59
commit 20ca0c5eaa
2 changed files with 10 additions and 6 deletions

View File

@ -10,10 +10,12 @@
#include <string.h>
#include "slab_private.h"
#include <util/AutoLock.h>
#include <vm/vm.h>
#include <vm/VMAddressSpace.h>
#include "slab_private.h"
static const size_t kCacheColorPeriod = 8;
@ -34,7 +36,10 @@ static void
object_cache_return_object_wrapper(object_depot* depot, void* cookie,
void* object)
{
object_cache_free((ObjectCache*)cookie, object);
ObjectCache* cache = (ObjectCache*)cookie;
MutexLocker _(cache->lock);
cache->ReturnObjectToSlab(cache->ObjectSlab(object), object);
}
@ -81,9 +86,8 @@ ObjectCache::Init(const char* name, size_t objectSize,
resize_request = NULL;
// TODO: depot destruction is obviously broken
// no gain in using the depot in single cpu setups
//if (smp_get_num_cpus() == 1)
if (smp_get_num_cpus() == 1)
this->flags |= CACHE_NO_DEPOT;
if (!(this->flags & CACHE_NO_DEPOT)) {

View File

@ -478,11 +478,11 @@ delete_object_cache(object_cache* cache)
sObjectCaches.Remove(cache);
}
mutex_lock(&cache->lock);
if (!(cache->flags & CACHE_NO_DEPOT))
object_depot_destroy(&cache->depot);
mutex_lock(&cache->lock);
unregister_low_resource_handler(object_cache_low_memory, cache);
if (!cache->full.IsEmpty())