From 6a43bd952f2c6e16a35ce506e1b0394048373fd6 Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Thu, 31 Mar 2011 17:59:23 +0200 Subject: [PATCH] Fix pthread_cond_wait() to prevent race --- mongoose.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongoose.c b/mongoose.c index 67da4c05..c702ff42 100644 --- a/mongoose.c +++ b/mongoose.c @@ -849,7 +849,7 @@ static int pthread_cond_wait(pthread_cond_t *cv, pthread_mutex_t *mutex) { HANDLE handles[] = {cv->signal, cv->broadcast}; ReleaseMutex(*mutex); WaitForMultipleObjects(2, handles, FALSE, INFINITE); - return ReleaseMutex(*mutex) == 0 ? -1 : 0; + return WaitForSingleObject(*mutex, INFINITE) == WAIT_OBJECT_0? 0 : -1; } static int pthread_cond_signal(pthread_cond_t *cv) {