ソースを参照

Fix pthread_cond_wait() to prevent race

Sergey Lyubka 14 年 前
コミット
6a43bd952f
1 ファイル変更1 行追加1 行削除
  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) {