diff options
author | rpj <rpj> | 2005-05-16 15:42:44 +0000 |
---|---|---|
committer | rpj <rpj> | 2005-05-16 15:42:44 +0000 |
commit | a824c43d3f20fc5722c5fd8f0f942f632b961723 (patch) | |
tree | e33174f1e54bcb5dffa3fb16be69713f4cc497c0 /pthread_win32_attach_detach_np.c | |
parent | 08e2916eb07fb75b2907032e2418316bf980d945 (diff) |
''
Diffstat (limited to 'pthread_win32_attach_detach_np.c')
-rw-r--r-- | pthread_win32_attach_detach_np.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/pthread_win32_attach_detach_np.c b/pthread_win32_attach_detach_np.c index 6947080..d839c70 100644 --- a/pthread_win32_attach_detach_np.c +++ b/pthread_win32_attach_detach_np.c @@ -261,15 +261,29 @@ pthread_win32_thread_detach_np () */ ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); - if (sp != NULL) + if (sp != NULL) // otherwise Win32 thread with no implicit POSIX handle. { + HANDLE threadH = sp->threadH; + + ptw32_callUserDestroyRoutines (sp->ptHandle); + + (void) pthread_mutex_lock (&sp->cancelLock); + sp->state = PThreadStateLast; /* - * Detached threads have their resources automatically - * cleaned up upon exit (others must be 'joined'). + * If the thread is joinable at this point then it MUST be joined + * or detached explicitly by the application. */ + (void) pthread_mutex_unlock (&sp->cancelLock); + if (sp->detachState == PTHREAD_CREATE_DETACHED) { ptw32_threadDestroy (sp->ptHandle); + + if (threadH != 0) + { + CloseHandle (threadH); + } + TlsSetValue (ptw32_selfThreadKey->key, NULL); } } |