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:
rfm 2009-01-30 10:22:50 +00:00
parent e49043462b
commit c22bfff738
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> 2009-01-29 17:49-EST Gregory John Casamento <greg_casamento@yahoo.com>
* Source/NSLock.m: Change to correct documented/tested and observed * 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 // NSLock class
// Simplest lock for protecting critical sections of code // Simplest lock for protecting critical sections of code
@ -455,8 +447,11 @@ NSString *NSRecursiveLockException = @"NSRecursiveLockException";
- (BOOL) tryLock - (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 // Ask the runtime to acquire a lock on the mutex
if (objc_mutex_trylock(_MUTEX) == -1) if (objc_mutex_trylock(_MUTEX) == -1)
return NO; return NO;