[vlc-devel] commit: libvlc_event_*: fix locking (Jean-Paul Saman )

Rémi Denis-Courmont remi at remlab.net
Tue May 12 16:14:40 CEST 2009


On Tue, 12 May 2009 14:26:51 +0200 (CEST), git at videolan.org (git version
control) wrote:
> vlc | branch: master | Jean-Paul Saman <jpsaman at videolan.org> | Tue May
12
> 12:39:50 2009 +0200| [13b7d257de1eced08708034186e290c0a5f5628a] |
> committer: Jean-Paul Saman
> 
> libvlc_event_*: fix locking
> 
>>
>
http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=13b7d257de1eced08708034186e290c0a5f5628a
> ---
> 
>  src/control/event.c |   37 ++++++++++++++++++++++++++++---------
>  1 files changed, 28 insertions(+), 9 deletions(-)
> 
> diff --git a/src/control/event.c b/src/control/event.c
> index d7f0b41..69d8b26 100644
> --- a/src/control/event.c
> +++ b/src/control/event.c
> @@ -93,8 +93,8 @@ void libvlc_event_manager_release(
> libvlc_event_manager_t * p_em )
>      libvlc_event_listeners_group_t * p_lg;
>      int i,j ;
> 
> -    vlc_mutex_destroy( &p_em->event_sending_lock );
> -    vlc_mutex_destroy( &p_em->object_lock );
> +    vlc_mutex_lock( &p_em->event_sending_lock );
> +    vlc_mutex_lock( &p_em->object_lock );

If someone where to call vlc_mutex_lock() at this point...

>      for( i = 0; i < vlc_array_count(&p_em->listeners_groups); i++)
>      {
> @@ -107,7 +107,15 @@ void libvlc_event_manager_release(
> libvlc_event_manager_t * p_em )
>          free( p_lg );
>      }
>      vlc_array_clear( &p_em->listeners_groups );
> +
> +    vlc_mutex_unlock( &p_em->object_lock );
> +    vlc_mutex_unlock( &p_em->event_sending_lock );

...it would get it at this point...

> +
>      libvlc_release( p_em->p_libvlc_instance );
> +
> +    vlc_mutex_destroy( &p_em->event_sending_lock );
> +    vlc_mutex_destroy( &p_em->object_lock );

...and would crash sometime after this.

In other words, this makes absolutely no sense to me.

-- 
Rémi Denis-Courmont




More information about the vlc-devel mailing list