[vlc-devel] commit: Set the owner to 0 while releasing a recursive mutex ( Geoffroy Couprie )

git version control git at videolan.org
Wed Sep 10 17:13:40 CEST 2008


vlc | branch: master | Geoffroy Couprie <geo.couprie at gmail.com> | Wed Sep 10 14:26:43 2008 +0200| [67677f32c9e96657b3e236cb7a857228a9ff2f76] | committer: Rémi Denis-Courmont 

Set the owner to 0 while releasing a recursive mutex

I (and dionoea too, I think) encountered an "assertion failed self ==
0" when trying to play a file on win32. I think the following patch
solves this issue. If I understand correcly, the intended behaviour
was to zero the owner field of the mutex when releasing it.

Modified by Courmisch to use InterlockedExchange() directly.

Signed-off-by: Rémi Denis-Courmont <rdenis at simphalempin.com>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=67677f32c9e96657b3e236cb7a857228a9ff2f76
---

 src/misc/threads.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/misc/threads.c b/src/misc/threads.c
index e12bef2..e4eeaf8 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -352,7 +352,7 @@ void vlc_mutex_lock (vlc_mutex_t *p_mutex)
 
         /* We need to lock this recursive mutex */
         EnterCriticalSection (&p_mutex->mutex);
-        self = InterlockedCompareExchange (&p_mutex->owner, self, 0);
+        self = InterlockedExchange (&p_mutex->owner, self);
         assert (self == 0); /* no previous owner */
         return;
     }
@@ -383,9 +383,8 @@ void vlc_mutex_unlock (vlc_mutex_t *p_mutex)
         }
 
         /* We release the mutex */
-        DWORD self = GetCurrentThreadId ();
-        self = InterlockedCompareExchange (&p_mutex->owner, self, 0);
-        assert (self == GetCurrentThreadId ());
+        DWORD self = InterlockedExchange (&p_mutex->owner, 0);
+        assert (self == 0);
         /* fall through */
     }
     LeaveCriticalSection (&p_mutex->mutex);




More information about the vlc-devel mailing list