[vlc-devel] commit: vlc_timer_gettime: fix corner-case dead lock ( Rémi Denis-Courmont )
git version control
git at videolan.org
Mon Aug 3 18:38:08 CEST 2009
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Aug 3 19:35:37 2009 +0300| [1b9c3f12c850b65dc33d7d33bcaadcfdd128e84b] | committer: Rémi Denis-Courmont
vlc_timer_gettime: fix corner-case dead lock
If vlc_cancel() while the timer thread is between mwait() and
vlc_mutex_lock(), a dead lock would occur at vlc_join(). We need to
release the timer lock first.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1b9c3f12c850b65dc33d7d33bcaadcfdd128e84b
---
src/misc/pthread.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/misc/pthread.c b/src/misc/pthread.c
index 47ac478..d31e388 100644
--- a/src/misc/pthread.c
+++ b/src/misc/pthread.c
@@ -812,11 +812,16 @@ void vlc_timer_destroy (vlc_timer_t timer)
void vlc_timer_schedule (vlc_timer_t timer, bool absolute,
mtime_t value, mtime_t interval)
{
+ static vlc_mutex_t lock = VLC_STATIC_MUTEX;
+
+ vlc_mutex_lock (&lock);
vlc_mutex_lock (&timer->lock);
if (timer->value)
{
+ vlc_mutex_unlock (&timer->lock);
vlc_cancel (timer->thread);
vlc_join (timer->thread, NULL);
+ vlc_mutex_lock (&timer->lock);
timer->value = 0;
}
if ((value != 0)
@@ -827,6 +832,7 @@ void vlc_timer_schedule (vlc_timer_t timer, bool absolute,
timer->interval = interval;
}
vlc_mutex_unlock (&timer->lock);
+ vlc_mutex_unlock (&lock);
}
/**
More information about the vlc-devel
mailing list