From 20e4f92cf540b33a55c36a414b63057b948417dc Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 23 Feb 2008 16:01:59 +0000 Subject: [PATCH] switch_sem_etc() doesn't check the return value of add_timer(), hence we need to make sure that we never get that far with a negative timeout or we'll wait forever. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24083 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/sem.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/system/kernel/sem.cpp b/src/system/kernel/sem.cpp index 47aa561809..234b099269 100644 --- a/src/system/kernel/sem.cpp +++ b/src/system/kernel/sem.cpp @@ -864,11 +864,16 @@ switch_sem_etc(sem_id semToBeReleased, sem_id id, int32 count, goto err; } - if (sSems[slot].u.used.count - count < 0 && (flags & B_RELATIVE_TIMEOUT) != 0 - && timeout <= 0) { - // immediate timeout - status = B_WOULD_BLOCK; - goto err; + if (sSems[slot].u.used.count - count < 0) { + if ((flags & B_RELATIVE_TIMEOUT) != 0 && timeout <= 0) { + // immediate timeout + status = B_WOULD_BLOCK; + goto err; + } else if ((flags & B_ABSOLUTE_TIMEOUT) != 0 && timeout < 0) { + // absolute negative timeout + status = B_TIMED_OUT; + goto err; + } } if ((sSems[slot].u.used.count -= count) < 0) {