From 564c60d8309d1e5a785a2ae3ba2edeb5feb79d82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sun, 3 Jun 2007 21:52:11 +0000 Subject: [PATCH] Fixed an initialization problem of the ReadWriteLock pointed out by geist, also added a comment on how the ownership is used when doing read locking. Thanks! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21314 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/file_systems/bfs/Lock.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/Lock.h b/src/add-ons/kernel/file_systems/bfs/Lock.h index a55553e600..eec8830683 100644 --- a/src/add-ons/kernel/file_systems/bfs/Lock.h +++ b/src/add-ons/kernel/file_systems/bfs/Lock.h @@ -1,12 +1,15 @@ -/* Lock - simple semaphores, read/write lock implementation - * Roughly based on a Be sample code written by Nathan Schrenk. +/* * - * Copyright 2001-2006, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2001-2007, Axel Dörfler, axeld@pinc-software.de. * This file may be used under the terms of the MIT License. */ #ifndef LOCK_H #define LOCK_H +/*! Simple semaphores, read/write lock implementation + Roughly based on a Be sample code written by Nathan Schrenk. +*/ + #include "system_dependencies.h" #include "Utility.h" @@ -333,11 +336,16 @@ class ReadWriteLock { class ReadWriteLock { public: ReadWriteLock(const char *name) + : + fOwner(-1) { Initialize(name); } ReadWriteLock() + : + fSemaphore(-1), + fOwner(-1) { } @@ -362,6 +370,7 @@ class ReadWriteLock { status_t Lock() { + // This allows nested locking when holding a write lock thread_id currentThread = find_thread(NULL); if (currentThread == fOwner) { fOwnerCount++;