| Index: nspr/pr/src/pthreads/ptthread.c
|
| ===================================================================
|
| --- nspr/pr/src/pthreads/ptthread.c (revision 251855)
|
| +++ nspr/pr/src/pthreads/ptthread.c (working copy)
|
| @@ -52,6 +52,7 @@
|
| PRInt32 system, user; /* a count of the two different types */
|
| PRUintn this_many; /* number of threads allowed for exit */
|
| pthread_key_t key; /* thread private data key */
|
| + PRBool keyCreated; /* whether 'key' should be deleted */
|
| PRThread *first, *last; /* list of threads we know about */
|
| #if defined(_PR_DCETHREADS) || defined(_POSIX_THREAD_PRIORITY_SCHEDULING)
|
| PRInt32 minPrio, maxPrio; /* range of scheduling priorities */
|
| @@ -979,9 +980,11 @@
|
| * nothing.
|
| */
|
| rv = _PT_PTHREAD_KEY_CREATE(&pt_book.key, _pt_thread_death);
|
| + if (0 != rv)
|
| + PR_Assert("0 == rv", __FILE__, __LINE__);
|
| + pt_book.keyCreated = PR_TRUE;
|
| + rv = pthread_setspecific(pt_book.key, thred);
|
| PR_ASSERT(0 == rv);
|
| - rv = pthread_setspecific(pt_book.key, thred);
|
| - PR_ASSERT(0 == rv);
|
| } /* _PR_InitThreads */
|
|
|
| #ifdef __GNUC__
|
| @@ -1041,7 +1044,17 @@
|
| void *thred;
|
| int rv;
|
|
|
| - if (!_pr_initialized) return;
|
| + if (!_pr_initialized) {
|
| + /* Either NSPR was never successfully initialized or
|
| + * PR_Cleanup has been called already. */
|
| + if (pt_book.keyCreated)
|
| + {
|
| + rv = pthread_key_delete(pt_book.key);
|
| + PR_ASSERT(0 == rv);
|
| + pt_book.keyCreated = PR_FALSE;
|
| + }
|
| + return;
|
| + }
|
|
|
| _PT_PTHREAD_GETSPECIFIC(pt_book.key, thred);
|
| if (NULL != thred)
|
| @@ -1056,6 +1069,7 @@
|
| }
|
| rv = pthread_key_delete(pt_book.key);
|
| PR_ASSERT(0 == rv);
|
| + pt_book.keyCreated = PR_FALSE;
|
| /* TODO: free other resources used by NSPR */
|
| /* _pr_initialized = PR_FALSE; */
|
| } /* _PR_Fini */
|
|
|