From 1d136d5a76951b5b9a07617db2cbc37c799a3245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 19 Aug 2008 08:40:55 +0000 Subject: [PATCH] * Fixed bug #2631 based on a patch by Salvatore: the block cache was put into a global list before it was fully initialized. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27058 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/cache/block_cache.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/system/kernel/cache/block_cache.cpp b/src/system/kernel/cache/block_cache.cpp index bc089ff6d3..f0cab224f6 100644 --- a/src/system/kernel/cache/block_cache.cpp +++ b/src/system/kernel/cache/block_cache.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2004-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2004-2008, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -771,10 +771,6 @@ block_cache::block_cache(int _fd, off_t numBlocks, size_t blockSize, read_only(readOnly), deleting(false) { - mutex_lock(&sCachesLock); - sCaches.Add(this); - mutex_unlock(&sCachesLock); - condition_variable.Publish(this, "cache transaction sync"); buffer_cache = create_object_cache_etc("block cache buffers", blockSize, @@ -793,8 +789,12 @@ block_cache::block_cache(int _fd, off_t numBlocks, size_t blockSize, return; mutex_init(&lock, "block cache"); + register_low_resource_handler(&block_cache::LowMemoryHandler, this, B_KERNEL_RESOURCE_PAGES | B_KERNEL_RESOURCE_MEMORY, 0); + + MutexLocker _(sCachesLock); + sCaches.Add(this); } @@ -803,16 +803,16 @@ block_cache::~block_cache() { deleting = true; + mutex_lock(&sCachesLock); + sCaches.Remove(this); + mutex_unlock(&sCachesLock); + unregister_low_resource_handler(&block_cache::LowMemoryHandler, this); mutex_destroy(&lock); condition_variable.Unpublish(); - mutex_lock(&sCachesLock); - sCaches.Remove(this); - mutex_unlock(&sCachesLock); - hash_uninit(transaction_hash); hash_uninit(hash);