From 8e19e877610819b5be4092fd4ce9b4183b1bfd4b Mon Sep 17 00:00:00 2001 From: sesse Date: Sat, 6 Mar 2010 10:07:39 +0000 Subject: 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. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30852 b3059339-0415-0410-9bf9-f77b7e298cf2 --- loader/win32.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'loader') diff --git a/loader/win32.c b/loader/win32.c index a73924f59f..20c15f850c 100644 --- a/loader/win32.c +++ b/loader/win32.c @@ -890,7 +890,7 @@ static void* WINAPI expWaitForSingleObject(void* object, int duration) if (duration == 0) { if(ml->semaphore==0) ret = WAIT_FAILED; else { - ml->semaphore++; + ml->semaphore--; ret = WAIT_OBJECT_0; } } @@ -898,6 +898,7 @@ static void* WINAPI expWaitForSingleObject(void* object, int duration) if (ml->semaphore==0) pthread_cond_wait(ml->pc,ml->pm); ml->semaphore--; + ret = WAIT_OBJECT_0; } break; } -- cgit v1.2.3