From 135d6f060c5e5232311af77bd0d0f500e861290c Mon Sep 17 00:00:00 2001 From: rpj Date: Mon, 15 Feb 2010 14:13:58 +0000 Subject: Comments and code style changes --- pthread_win32_attach_detach_np.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'pthread_win32_attach_detach_np.c') 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); -- cgit v1.2.3