mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 08:41:03 +00:00
Fix recursion when looking up the current thread
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39351 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7f8d7e6270
commit
cdbaa85862
2 changed files with 15 additions and 11 deletions
|
@ -610,21 +610,17 @@ inline NSThread*
|
|||
GSCurrentThread(void)
|
||||
{
|
||||
NSThread *thr = pthread_getspecific(thread_object_key);
|
||||
|
||||
if (nil == thr)
|
||||
{
|
||||
NSValue *selfThread = NSValueCreateFromPthread(pthread_self());
|
||||
|
||||
/* NB this locked section cannot be protected by an exception handler
|
||||
* because the exception handler stores information in the current
|
||||
* thread variables ... which causes recursion.
|
||||
*/
|
||||
[_exitingThreadsLock lock];
|
||||
NS_DURING
|
||||
{
|
||||
thr = NSMapGet(_exitingThreads, (const void*)selfThread);
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
[_exitingThreadsLock unlock];
|
||||
DESTROY(selfThread);
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
thr = NSMapGet(_exitingThreads, (const void*)selfThread);
|
||||
[_exitingThreadsLock unlock];
|
||||
DESTROY(selfThread);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue