From c22bfff738cd37d71442c3b35aa2186f9f978712 Mon Sep 17 00:00:00 2001 From: rfm Date: Fri, 30 Jan 2009 10:22:50 +0000 Subject: [PATCH] Fix to return correct value when -tryLock is attempted recursively. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27730 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 4 ++++ Source/NSLock.m | 15 +++++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4e450dd70..4cd46dd45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-01-30 Richard Frith-Macdonald + + * Source/NSLock.m: Fixed last change to match MacOS-X behavior. + 2009-01-29 17:49-EST Gregory John Casamento * Source/NSLock.m: Change to correct documented/tested and observed diff --git a/Source/NSLock.m b/Source/NSLock.m index 300a3b90e..04c0a9fc0 100644 --- a/Source/NSLock.m +++ b/Source/NSLock.m @@ -129,14 +129,6 @@ NSString *NSRecursiveLockException = @"NSRecursiveLockException"; } \ } -#define WARN_RECURSIVE_CONDITION_LOCK(mutex) \ -{ \ - if ((mutex)->owner == objc_thread_id()) \ - { \ - NSLog(@"WARNING: Thread attempted to recursively lock: %@",self); \ - } \ -} - // NSLock class // Simplest lock for protecting critical sections of code @@ -455,8 +447,11 @@ NSString *NSRecursiveLockException = @"NSRecursiveLockException"; - (BOOL) tryLock { - WARN_RECURSIVE_CONDITION_LOCK(_MUTEX); - + if ((_MUTEX)->owner == objc_thread_id()) + { + NSLog(@"WARNING: Thread attempted to recursively tryLock : %@", self); + return NO; + } // Ask the runtime to acquire a lock on the mutex if (objc_mutex_trylock(_MUTEX) == -1) return NO;