diff options
Diffstat (limited to 'pthread_cond_wait.c')
-rw-r--r-- | pthread_cond_wait.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/pthread_cond_wait.c b/pthread_cond_wait.c index 6db2a48..241f464 100644 --- a/pthread_cond_wait.c +++ b/pthread_cond_wait.c @@ -284,6 +284,17 @@ ptw32_cond_wait_cleanup (void *args) int result; /* + * XSH: Upon successful return, the mutex has been locked and is owned + * by the calling thread. This must be done before any cancelation + * cleanup handlers are run. + */ + if ((result = pthread_mutex_lock (cleanup_args->mutexPtr)) != 0) + { + *resultPtr = result; + return; + } + + /* * Whether we got here as a result of signal/broadcast or because of * timeout on wait or thread cancellation we indicate that we are no * longer waiting. The waiter is responsible for adjusting waiters @@ -340,16 +351,6 @@ ptw32_cond_wait_cleanup (void *args) return; } } - - /* - * XSH: Upon successful return, the mutex has been locked and is owned - * by the calling thread - */ - if ((result = pthread_mutex_lock (cleanup_args->mutexPtr)) != 0) - { - *resultPtr = result; - } - } /* ptw32_cond_wait_cleanup */ static INLINE int |