Sfoglia il codice sorgente

Replacement for pthread_cond in Windows

bel 11 anni fa
parent
commit
da44a66fc1
1 ha cambiato i file con 5 aggiunte e 1 eliminazioni
  1. 5 1
      src/civetweb.c

+ 5 - 1
src/civetweb.c

@@ -1087,7 +1087,7 @@ static int pthread_cond_wait(pthread_cond_t *cv, pthread_mutex_t *mutex)
     LeaveCriticalSection(&cv->threadIdSec);
 
     pthread_mutex_unlock(mutex); /* if the thread is preempted here, ResumeThread will return 0 */
-    SuspendThread(GetCurrentThread()); /* if the thread reached this point, ResuleThread will return 1 */
+    SuspendThread(GetCurrentThread()); /* if the thread reached this point, ResumeThread will return 1 */
     pthread_mutex_lock(mutex);
 
     return 0;
@@ -1133,8 +1133,12 @@ static int pthread_cond_broadcast(pthread_cond_t *cv)
 
 static int pthread_cond_destroy(pthread_cond_t *cv)
 {
+    EnterCriticalSection(&cv->threadIdSec);
     assert(cv->waitingthreadcount==0);
+    cv->waitingthreadids = 0;
     free(cv->waitingthreadids);
+    LeaveCriticalSection(&cv->threadIdSec);
+    DeleteCriticalSection(&cv->threadIdSec);
 
     return 0;
 }