[vlc-devel] [PATCH] audiotrack: fix benign race

Thomas Guillem thomas at gllm.fr
Thu Mar 5 18:25:54 CET 2015



On Thu, Mar 5, 2015, at 17:45, Rémi Denis-Courmont wrote:
> Le 2015-03-05 19:38, Thomas Guillem a écrit :
> > ---
> >  modules/audio_output/audiotrack.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/modules/audio_output/audiotrack.c
> > b/modules/audio_output/audiotrack.c
> > index 7ac723a..09f7588 100644
> > --- a/modules/audio_output/audiotrack.c
> > +++ b/modules/audio_output/audiotrack.c
> > @@ -1221,6 +1221,7 @@ Open( vlc_object_t *obj )
> >
> >      aout_SoftVolumeInit( p_aout );
> >
> > +    vlc_mutex_lock( &p_sys->mutex );
> >      /* create JNIThread */
> >      p_sys->b_thread_run = true;
> >      if( vlc_clone( &p_sys->thread,
> > @@ -1228,9 +1229,11 @@ Open( vlc_object_t *obj )
> >      {
> >          msg_Err( p_aout, "JNIThread creation failed" );
> >          p_sys->b_thread_run = false;
> > +        vlc_mutex_unlock( &p_sys->mutex );
> >          Close( obj );
> >          return VLC_EGENERIC;
> >      }
> > +    vlc_mutex_unlock( &p_sys->mutex );
> >
> >      return VLC_SUCCESS;
> >  }
> 
> If the thread is not created, then there is no thread to race against.

OK, I was not really sure about locking thread creation or not, but now
it's obvious.

> If the thread is created, I don't see what the race is about.
> 
> -- 
> Rémi Denis-Courmont
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list