From 4c0f46e2a3a5a767317600e9ddf01042d21e6481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 16 Dec 2005 15:50:13 +0000 Subject: [PATCH] The block_cache::LowMemoryHandler() must check if it could acquire the cache's lock; it might have been deleted in the mean time. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15565 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/cache/block_cache.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/system/kernel/cache/block_cache.cpp b/src/system/kernel/cache/block_cache.cpp index e8d8e450aa..1b9f91fa02 100644 --- a/src/system/kernel/cache/block_cache.cpp +++ b/src/system/kernel/cache/block_cache.cpp @@ -350,6 +350,13 @@ block_cache::LowMemoryHandler(void *data, int32 level) block_cache *cache = (block_cache *)data; BenaphoreLocker locker(&cache->lock); + if (!locker.IsLocked()) { + // If our block_cache were deleted, it could be that we had + // been called before that deletion went through, therefore, + // acquiring its lock might fail. + return; + } + TRACE(("block_cache: low memory handler called with level %ld\n", level)); // free some blocks according to the low memory state