[vlc-devel] commit: Win32: fix race condition initializing static mutexes ( Rémi Denis-Courmont )
git version control
git at videolan.org
Tue Dec 16 20:51:20 CET 2008
vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Tue Dec 16 21:51:04 2008 +0200| [1d0c9675a07d2fd61bacc26da66c5047305ddfee] | committer: Rémi Denis-Courmont
Win32: fix race condition initializing static mutexes
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1d0c9675a07d2fd61bacc26da66c5047305ddfee
---
src/misc/threads.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/misc/threads.c b/src/misc/threads.c
index a7c133e..4d618d4 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -360,7 +360,8 @@ void vlc_mutex_lock (vlc_mutex_t *p_mutex)
assert (p_mutex != &super_mutex); /* this one cannot be static */
vlc_mutex_lock (&super_mutex);
- vlc_mutex_init (p_mutex);
+ if (InterlockedCompareExchange (&p_mutex->initialized, 0, 0) == 0)
+ vlc_mutex_init (p_mutex);
/* FIXME: destroy the mutex some time... */
vlc_mutex_unlock (&super_mutex);
}
More information about the vlc-devel
mailing list