Explorar o código

Fix pthread_cond_wait() to prevent race

Sergey Lyubka %!s(int64=14) %!d(string=hai) anos
pai
achega
6a43bd952f
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      mongoose.c

+ 1 - 1
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) {