diff --git a/src/system/kernel/slab/ObjectCache.cpp b/src/system/kernel/slab/ObjectCache.cpp index 87cc221bcb..2a0663a8bd 100644 --- a/src/system/kernel/slab/ObjectCache.cpp +++ b/src/system/kernel/slab/ObjectCache.cpp @@ -10,10 +10,12 @@ #include -#include "slab_private.h" +#include #include #include +#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)) { diff --git a/src/system/kernel/slab/Slab.cpp b/src/system/kernel/slab/Slab.cpp index aa6aeb6e09..1d476d7e7f 100644 --- a/src/system/kernel/slab/Slab.cpp +++ b/src/system/kernel/slab/Slab.cpp @@ -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())