Web lists-archives.org

[MPlayer-dev-eng] [PATCH] 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.

/* Steinar */
-- 
Homepage: http://www.sesse.net/
Index: loader/win32.c
===================================================================
--- loader/win32.c	(revisjon 30837)
+++ loader/win32.c	(arbeidskopi)
@@ -846,7 +846,7 @@
 	if (duration == 0) {
 	    if(ml->semaphore==0) ret = WAIT_FAILED;
 	    else {
-		ml->semaphore++;
+		ml->semaphore--;
 		ret = WAIT_OBJECT_0;
 	    }
 	}
@@ -854,6 +854,7 @@
 	    if (ml->semaphore==0)
 		pthread_cond_wait(ml->pc,ml->pm);
 	    ml->semaphore--;
+	    ret = WAIT_OBJECT_0;
 	}
 	break;
     }
_______________________________________________
MPlayer-dev-eng mailing list
MPlayer-dev-eng@xxxxxxxxxxxx
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng