changeset 30810:60c9c064d43f

Fix semaphore behavior in WaitForSingleObject. Two simple bugfixes for semaphores in WaitForSingleObject: First, semaphore count should be decreased on loading the semaphore, not increased. The case for duration=0 had this wrong (duration=-1 was fine). Second, the code for duration=-1 forgot to set the return value, so it would always return WAIT_FAILED.
author sesse
date Sat, 06 Mar 2010 10:07:39 +0000
parents d01c83dcb634
children 50e0f6942e43
files loader/win32.c
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/loader/win32.c	Sat Mar 06 10:05:10 2010 +0000
+++ b/loader/win32.c	Sat Mar 06 10:07:39 2010 +0000
@@ -890,7 +890,7 @@
 	if (duration == 0) {
 	    if(ml->semaphore==0) ret = WAIT_FAILED;
 	    else {
-		ml->semaphore++;
+		ml->semaphore--;
 		ret = WAIT_OBJECT_0;
 	    }
 	}
@@ -898,6 +898,7 @@
 	    if (ml->semaphore==0)
 		pthread_cond_wait(ml->pc,ml->pm);
 	    ml->semaphore--;
+	    ret = WAIT_OBJECT_0;
 	}
 	break;
     }