X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fthread%2Fpthread_cond_timedwait.c;h=3526ecfb6d2eee92817dd00da769fe9dc3bdb4f4;hb=8c316e9e49d37ad92c2e7493e16166a2afca419f;hp=f5fd08c099703dacd56950269adf3cdb616b45d2;hpb=0fc317d83c1167393bf276a8bfbdd9a4e02e8258;p=musl diff --git a/src/thread/pthread_cond_timedwait.c b/src/thread/pthread_cond_timedwait.c index f5fd08c0..3526ecfb 100644 --- a/src/thread/pthread_cond_timedwait.c +++ b/src/thread/pthread_cond_timedwait.c @@ -29,8 +29,8 @@ int __pthread_setcancelstate(int, int *); struct waiter { struct waiter *prev, *next; - int state, barrier; - int *notify; + volatile int state, barrier; + volatile int *notify; }; /* Self-synchronized-destruction-safe lock functions */ @@ -67,7 +67,8 @@ enum { int __pthread_cond_timedwait(pthread_cond_t *restrict c, pthread_mutex_t *restrict m, const struct timespec *restrict ts) { struct waiter node = { 0 }; - int e, seq, *fut, clock = c->_c_clock, cs, shared=0, oldstate, tmp; + int e, seq, clock = c->_c_clock, cs, shared=0, oldstate, tmp; + volatile int *fut; if ((m->_m_type&15) && (m->_m_lock&INT_MAX) != __pthread_self()->tid) return EPERM; @@ -99,6 +100,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)); @@ -175,7 +177,8 @@ done: int __private_cond_signal(pthread_cond_t *c, int n) { struct waiter *p, *first=0; - int ref = 0, cur; + volatile int ref = 0; + int cur; lock(&c->_c_lock); for (p=c->_c_tail; n && p; p=p->prev) {