diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | pthread_setspecific.c | 2 | ||||
-rw-r--r-- | pthread_win32_attach_detach_np.c | 6 |
3 files changed, 13 insertions, 4 deletions
@@ -1,3 +1,12 @@ +2003-05-15 Steven Reddie <Steven.Reddie@ca.com> + + * pthread_win32_attach_detach_np.c (pthread_win32_process_detach_np): + NULLify ptw32_selfThreadKey after the thread is destroyed, otherwise + destructors calling pthreads routines might resurrect it again, creating + memory leaks. Call the underlying Win32 Tls routine directly rather than + pthread_setspecific(). + (pthread_win32_thread_detach_np): Likewise. + 2003-05-14 Viv <vcotirlea@hotmail.com> * pthread.dsp: Change /MT compile flag to /MD. diff --git a/pthread_setspecific.c b/pthread_setspecific.c index 37ff975..fbf4d7e 100644 --- a/pthread_setspecific.c +++ b/pthread_setspecific.c @@ -84,7 +84,7 @@ pthread_setspecific (pthread_key_t key, const void *value) else { /* - * Resolve catch-22 of registering thread with threadSelf + * Resolve catch-22 of registering thread with selfThread * key */ self = (pthread_t) pthread_getspecific (ptw32_selfThreadKey); diff --git a/pthread_win32_attach_detach_np.c b/pthread_win32_attach_detach_np.c index 487bcbb..5e662b5 100644 --- a/pthread_win32_attach_detach_np.c +++ b/pthread_win32_attach_detach_np.c @@ -115,12 +115,12 @@ pthread_win32_process_detach_np () if (self != NULL && self->detachState == PTHREAD_CREATE_DETACHED) { - pthread_setspecific (ptw32_selfThreadKey, NULL); ptw32_threadDestroy (self); + TlsSetValue (ptw32_selfThreadKey->key, NULL); } /* - * The DLL is being unmapped into the process's address space + * The DLL is being unmapped from the process's address space */ ptw32_processTerminate (); @@ -153,8 +153,8 @@ pthread_win32_thread_detach_np () if (self != NULL && self->detachState == PTHREAD_CREATE_DETACHED) { - pthread_setspecific (ptw32_selfThreadKey, NULL); ptw32_threadDestroy (self); + TlsSetValue (ptw32_selfThreadKey->key, NULL); } } |