Commit 67677f32 authored by Geoffroy Couprie's avatar Geoffroy Couprie Committed by 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: default avatarRémi Denis-Courmont <rdenis@simphalempin.com>
parent d31ffb66
...@@ -352,7 +352,7 @@ void vlc_mutex_lock (vlc_mutex_t *p_mutex) ...@@ -352,7 +352,7 @@ void vlc_mutex_lock (vlc_mutex_t *p_mutex)
/* We need to lock this recursive mutex */ /* We need to lock this recursive mutex */
EnterCriticalSection (&p_mutex->mutex); EnterCriticalSection (&p_mutex->mutex);
self = InterlockedCompareExchange (&p_mutex->owner, self, 0); self = InterlockedExchange (&p_mutex->owner, self);
assert (self == 0); /* no previous owner */ assert (self == 0); /* no previous owner */
return; return;
} }
...@@ -383,9 +383,8 @@ void vlc_mutex_unlock (vlc_mutex_t *p_mutex) ...@@ -383,9 +383,8 @@ void vlc_mutex_unlock (vlc_mutex_t *p_mutex)
} }
/* We release the mutex */ /* We release the mutex */
DWORD self = GetCurrentThreadId (); DWORD self = InterlockedExchange (&p_mutex->owner, 0);
self = InterlockedCompareExchange (&p_mutex->owner, self, 0); assert (self == 0);
assert (self == GetCurrentThreadId ());
/* fall through */ /* fall through */
} }
LeaveCriticalSection (&p_mutex->mutex); LeaveCriticalSection (&p_mutex->mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment