diff options
author | rpj <rpj> | 2010-02-15 14:13:58 +0000 |
---|---|---|
committer | rpj <rpj> | 2010-02-15 14:13:58 +0000 |
commit | 135d6f060c5e5232311af77bd0d0f500e861290c (patch) | |
tree | 1b8a6c26c2e7cfbee073a7c138a564296934882a /pthread_win32_attach_detach_np.c | |
parent | 866c278580edc88765929fdbc5235d15bab44d3d (diff) |
Comments and code style changes
Diffstat (limited to 'pthread_win32_attach_detach_np.c')
-rw-r--r-- | pthread_win32_attach_detach_np.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/pthread_win32_attach_detach_np.c b/pthread_win32_attach_detach_np.c index 7911fe1..5bbd925 100644 --- a/pthread_win32_attach_detach_np.c +++ b/pthread_win32_attach_detach_np.c @@ -283,7 +283,7 @@ pthread_win32_thread_detach_np () */ ptw32_thread_t * sp = (ptw32_thread_t *) pthread_getspecific (ptw32_selfThreadKey); - if (sp != NULL) // otherwise Win32 thread with no implicit POSIX handle. + if (sp != NULL) { ptw32_callUserDestroyRoutines (sp->ptHandle); @@ -291,10 +291,16 @@ pthread_win32_thread_detach_np () sp->state = PThreadStateLast; /* * If the thread is joinable at this point then it MUST be joined - * or detached explicitly by the application. + * or detached explicitly by the application because it's + * detachState cannot be changed from this point on. */ (void) pthread_mutex_unlock (&sp->cancelLock); + /* + * No race condition here because detachState will not be changed + * elsewhere now that thread state is PThreadStateLast (set above + * behind mutex). + */ if (sp->detachState == PTHREAD_CREATE_DETACHED) { ptw32_threadDestroy (sp->ptHandle); |