* 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
This commit is contained in:
@@ -42,6 +42,8 @@ benaphore_init(benaphore *ben, const char *name)
|
|||||||
static inline status_t
|
static inline status_t
|
||||||
benaphore_lock_etc(benaphore *ben, uint32 flags, bigtime_t timeout)
|
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)
|
if (atomic_add(&ben->count, -1) <= 0)
|
||||||
return acquire_sem_etc(ben->sem, 1, flags, timeout);
|
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
|
static inline status_t
|
||||||
benaphore_lock(benaphore *ben)
|
benaphore_lock(benaphore *ben)
|
||||||
{
|
{
|
||||||
if (atomic_add(&ben->count, -1) <= 0)
|
if (atomic_add(&ben->count, -1) <= 0) {
|
||||||
return acquire_sem(ben->sem);
|
status_t error;
|
||||||
|
do {
|
||||||
|
error = acquire_sem(ben->sem);
|
||||||
|
} while (error == B_INTERRUPTED);
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user