/* wait until this event was processed */ ret = 0; while (!ret && (sub_shm->lock.readers || (!SR_IS_NOTIFY_EVENT(sub_shm->event) && (sub_shm->event != SR_SUB_EV_NONE)))) { /* COND WAIT */ ret = pthread_cond_timedwait(&sub_shm->lock.cond, &sub_shm->lock.mutex, &timeout_ts); }
if (ret) { if (ret == ETIMEDOUT) { /* handle corner-case when the subscriber has just woken up and is processing this event, * lock should never be held for long */ sr_time_get(&timeout_ts, SR_RWLOCK_READ_TIMEOUT); while (sub_shm->lock.readers) { /* COND WAIT */ pthread_cond_timedwait(&sub_shm->lock.cond, &sub_shm->lock.mutex, &timeout_ts); }
int ___pthread_cond_timedwait64 (pthread_cond_t *cond, pthread_mutex_t *mutex, conststruct __timespec64 *abstime) { /* Check parameter validity. This should also tell the compiler that it can assume that abstime is not NULL. */ if (! valid_nanoseconds (abstime->tv_nsec)) return EINVAL;
/* Relaxed MO is suffice because clock ID bit is only modified in condition creation. */ unsignedint flags = atomic_load_relaxed (&cond->__data.__wrefs); clockid_t clockid = (flags & __PTHREAD_COND_CLOCK_MONOTONIC_MASK) ? CLOCK_MONOTONIC : CLOCK_REALTIME; return __pthread_cond_wait_common (cond, mutex, clockid, abstime); }