# HG changeset patch # User sesse # Date 1267870059 0 # Node ID 60c9c064d43f137b05184ac588479f687c47c498 # Parent d01c83dcb634a704b6d492ddc79c3a6ba49f19a8 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. diff -r d01c83dcb634 -r 60c9c064d43f loader/win32.c --- 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; }