[vlc-devel] [PATCH] timer: add a few explicit cancellation points
Rémi Denis-Courmont
remi at remlab.net
Tue Aug 19 08:47:50 CEST 2014
Le 2014-08-19 00:48, Sean McGovern a écrit :
> ---
> I highly suspect this patch is JustPlainWrong, but it does
> "fix" the catatonic thread problem on newer versions of
> OS X. Comments welcome.
> ---
> src/posix/timer.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/src/posix/timer.c b/src/posix/timer.c
> index 71ca080..cd2ca63 100644
> --- a/src/posix/timer.c
> +++ b/src/posix/timer.c
> @@ -59,12 +59,17 @@ static void *vlc_timer_thread (void *data)
>
> for (;;)
> {
> - while (timer->value == 0)
> + vlc_testcancel();
No. This makes no sense considering the documented definition of
vlc_cond_wait().
> + while (timer->value == 0) {
> vlc_cond_wait (&timer->reschedule, &timer->lock);
> + vlc_testcancel();
Ditto.
> + }
>
> if (vlc_cond_timedwait (&timer->reschedule, &timer->lock,
> - timer->value) == 0)
> + timer->value) == 0) {
> + vlc_testcancel();
Ditto.
> continue;
> + }
> if (timer->interval == 0)
> timer->value = 0; /* disarm */
> vlc_mutex_unlock (&timer->lock);
> @@ -149,6 +154,7 @@ int vlc_timer_create (vlc_timer_t *id, void
> (*func) (void *), void *data)
> void vlc_timer_destroy (vlc_timer_t timer)
> {
> vlc_cancel (timer->thread);
> + vlc_cond_broadcast(&timer->reschedule);
Ditto.
> vlc_join (timer->thread, NULL);
> vlc_cond_destroy (&timer->reschedule);
> vlc_mutex_destroy (&timer->lock);
Rejected.
--
Rémi Denis-Courmont
More information about the vlc-devel
mailing list