Bugzilla bug 214411: fixed a bug introduced in the previous checkin.

threadid_key_destructor may get called on the primordial thread if the app
doesn't call PR_Cleanup and the assertion would fail.  Thanks to
Gerard Roos <gerard.roos@adnovum.ch> for contributing the patch.
This commit is contained in:
wchang0222%aol.com 2003-10-23 00:43:36 +00:00
parent 039566e00c
commit 3d84d300c8

View File

@ -187,16 +187,19 @@ static void
threadid_key_destructor(void *value)
{
PRThread *me = (PRThread *)value;
PR_ASSERT((me != NULL) && (me->flags & _PR_ATTACHED));
/*
* The Solaris thread library sets the thread specific
* data (the current thread) to NULL before invoking
* the destructor. We need to restore it to prevent the
* _PR_MD_CURRENT_THREAD() call in _PRI_DetachThread()
* from attaching the thread again.
*/
_PR_MD_SET_CURRENT_THREAD(me);
_PRI_DetachThread();
PR_ASSERT(me != NULL);
/* the thread could be PRIMORDIAL (thus not ATTACHED) */
if (me->flags & _PR_ATTACHED) {
/*
* The Solaris thread library sets the thread specific
* data (the current thread) to NULL before invoking
* the destructor. We need to restore it to prevent the
* _PR_MD_CURRENT_THREAD() call in _PRI_DetachThread()
* from attaching the thread again.
*/
_PR_MD_SET_CURRENT_THREAD(me);
_PRI_DetachThread();
}
}
void _MD_EarlyInit(void)