[vlc-devel] [PATCH 3/7] posix: remove cancellation in vlc_atomic_wait()

Rémi Denis-Courmont remi at remlab.net
Tue Apr 14 21:57:08 CEST 2020


Le tiistaina 14. huhtikuuta 2020, 22.53.40 EEST Marvin Scholz a écrit :
> On 14 Apr 2020, at 21:45, Rémi Denis-Courmont wrote:
> > ---
> > 
> >  src/posix/wait.c | 26 +++++++++++++-------------
> >  1 file changed, 13 insertions(+), 13 deletions(-)
> > 
> > diff --git a/src/posix/wait.c b/src/posix/wait.c
> > index dfb0c508db..380e3cf5e7 100644
> > --- a/src/posix/wait.c
> > +++ b/src/posix/wait.c
> > @@ -66,10 +66,8 @@ static struct wait_bucket
> > *wait_bucket_enter(atomic_uint *addr)
> > 
> >      return bucket;
> >  
> >  }
> > 
> > -static void wait_bucket_leave(void *data)
> > +static void wait_bucket_leave(struct wait_bucker *bucket)
> 
> Isn't there a typo, wait_bucker instead of wait_bucket?

Yes there is, but the whole patchset is busted because of the fingerprinter 
changes made in the mean time.

> 
> >  {
> > 
> > -    struct wait_bucket *bucket = data;
> > -
> > 
> >      bucket->waiters--;
> >      pthread_mutex_unlock(&bucket->lock);
> >  
> >  }
> > 
> > @@ -79,14 +77,15 @@ void vlc_atomic_wait(void *addr, unsigned value)
> > 
> >      atomic_uint *futex = addr;
> >      struct wait_bucket *bucket = wait_bucket_enter(futex);
> > 
> > -    pthread_cleanup_push(wait_bucket_leave, bucket);
> > +    if (value == atomic_load_explicit(futex, memory_order_relaxed)) {
> > +        int canc;
> > 
> > -    if (value == atomic_load_explicit(futex, memory_order_relaxed))
> > +        pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &canc);
> > 
> >          pthread_cond_wait(&bucket->wait, &bucket->lock);
> > 
> > -    else
> > -        pthread_testcancel();
> > +        pthread_setcancelstate(canc, NULL);
> > +    }
> > 
> > -    pthread_cleanup_pop(1);
> > +    wait_bucket_leave(bucket);
> > 
> >  }
> >  
> >  static int vlc_atomic_timedwait_timespec(void *addr, unsigned value,
> > 
> > @@ -96,14 +95,15 @@ static int vlc_atomic_timedwait_timespec(void
> > *addr, unsigned value,
> > 
> >      struct wait_bucket *bucket = wait_bucket_enter(futex);
> >      int ret = 0;
> > 
> > -    pthread_cleanup_push(wait_bucket_leave, bucket);
> > +    if (value == atomic_load_explicit(futex, memory_order_relaxed)) {
> > +        int canc;
> > 
> > -    if (value == atomic_load_explicit(futex, memory_order_relaxed))
> > +        pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &canc);
> > 
> >          ret = pthread_cond_timedwait(&bucket->wait, &bucket->lock,
> > 
> > ts);
> > -    else
> > -        pthread_testcancel();
> > +        pthread_setcancelstate(canc, NULL);
> > +    }
> > 
> > -    pthread_cleanup_pop(1);
> > +    wait_bucket_leave(bucket);
> > 
> >      return ret;
> >  
> >  }
> > 
> > _______________________________________________
> > vlc-devel mailing list
> > To unsubscribe or modify your subscription options:
> > https://mailman.videolan.org/listinfo/vlc-devel
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


-- 
Rémi Denis-Courmont
Tapiola new town, Uusimaan Republic





More information about the vlc-devel mailing list