rewrite __synccall in terms of global thread list
[musl] / src / thread / pthread_cond_timedwait.c
index 27b1a99..d150124 100644 (file)
@@ -1,10 +1,5 @@
 #include "pthread_impl.h"
 
-void __pthread_testcancel(void);
-int __pthread_mutex_lock(pthread_mutex_t *);
-int __pthread_mutex_unlock(pthread_mutex_t *);
-int __pthread_setcancelstate(int, int *);
-
 /*
  * struct waiter
  *
@@ -54,7 +49,7 @@ static inline void unlock_requeue(volatile int *l, volatile int *r, int w)
 {
        a_store(l, 0);
        if (w) __wake(l, 1, 1);
-       else __syscall(SYS_futex, l, FUTEX_REQUEUE|128, 0, 1, r) != -ENOSYS
+       else __syscall(SYS_futex, l, FUTEX_REQUEUE|FUTEX_PRIVATE, 0, 1, r) != -ENOSYS
                || __syscall(SYS_futex, l, FUTEX_REQUEUE, 0, 1, r);
 }
 
@@ -100,6 +95,7 @@ int __pthread_cond_timedwait(pthread_cond_t *restrict c, pthread_mutex_t *restri
        __pthread_mutex_unlock(m);
 
        __pthread_setcancelstate(PTHREAD_CANCEL_MASKED, &cs);
+       if (cs == PTHREAD_CANCEL_DISABLE) __pthread_setcancelstate(cs, 0);
 
        do e = __timedwait_cp(fut, seq, clock, ts, !shared);
        while (*fut==seq && (!e || e==EINTR));