From 3c529bf7fe96817102ec62e70bf1f34475fa5b4f Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 7 Sep 2008 15:27:14 +0000 Subject: [PATCH] * Retry in benaphore_lock() when interrupted. * Added TODO in benaphore_lock_etc(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27359 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/libroot/libroot_lock.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/headers/private/libroot/libroot_lock.h b/headers/private/libroot/libroot_lock.h index 5893ec4a46..597821fde7 100644 --- a/headers/private/libroot/libroot_lock.h +++ b/headers/private/libroot/libroot_lock.h @@ -42,6 +42,8 @@ benaphore_init(benaphore *ben, const char *name) static inline status_t benaphore_lock_etc(benaphore *ben, uint32 flags, bigtime_t timeout) { +// TODO: This function really shouldn't be used, since timeouts screw the +// benaphore behavior. if (atomic_add(&ben->count, -1) <= 0) return acquire_sem_etc(ben->sem, 1, flags, timeout); @@ -52,8 +54,14 @@ benaphore_lock_etc(benaphore *ben, uint32 flags, bigtime_t timeout) static inline status_t benaphore_lock(benaphore *ben) { - if (atomic_add(&ben->count, -1) <= 0) - return acquire_sem(ben->sem); + if (atomic_add(&ben->count, -1) <= 0) { + status_t error; + do { + error = acquire_sem(ben->sem); + } while (error == B_INTERRUPTED); + + return error; + } return B_OK; }