diff options
Diffstat (limited to 'sysdeps/mach/hurd/htl/pt-hurd-cond-timedwait.c')
-rw-r--r-- | sysdeps/mach/hurd/htl/pt-hurd-cond-timedwait.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sysdeps/mach/hurd/htl/pt-hurd-cond-timedwait.c b/sysdeps/mach/hurd/htl/pt-hurd-cond-timedwait.c index 16f0d3b309..1677925755 100644 --- a/sysdeps/mach/hurd/htl/pt-hurd-cond-timedwait.c +++ b/sysdeps/mach/hurd/htl/pt-hurd-cond-timedwait.c @@ -103,6 +103,12 @@ __pthread_hurd_cond_timedwait_internal (pthread_cond_t *cond, __pthread_spin_unlock (&cond->__lock); __spin_unlock (&ss->lock); + /* Increase the waiter reference count. Relaxed MO is sufficient because + we only need to synchronize when decrementing the reference count. + We however need to have the mutex held to prevent concurrency with + a pthread_cond_destroy. */ + atomic_fetch_add_relaxed (&cond->__wrefs, 2); + if (cancel) { /* Cancelled on entry. Just leave the mutex locked. */ @@ -115,10 +121,6 @@ __pthread_hurd_cond_timedwait_internal (pthread_cond_t *cond, /* Release MUTEX before blocking. */ __pthread_mutex_unlock (mutex); - /* Increase the waiter reference count. Relaxed MO is sufficient because - we only need to synchronize when decrementing the reference count. */ - atomic_fetch_add_relaxed (&cond->__wrefs, 2); - /* Block the thread. */ if (abstime != NULL) err = __pthread_timedblock (self, abstime, clock_id); |