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
This commit is contained in:
Richard Frith-MacDonald 2009-01-30 10:22:50 +00:00
parent f77a3d4091
commit 4006fb9f00
2 changed files with 9 additions and 10 deletions

View file

@ -1,3 +1,7 @@
2009-01-30 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSLock.m: Fixed last change to match MacOS-X behavior.
2009-01-29 17:49-EST Gregory John Casamento <greg_casamento@yahoo.com>
* Source/NSLock.m: Change to correct documented/tested and observed

View file

@ -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;