diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-07-23 08:28:51 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-07-23 08:28:51 +0100 |
| commit | 8cda61ab7fe436075a7d93306819a609de80c4a0 (patch) | |
| tree | 6bb5089addac60eae652391ce59c3725b30b080a /dev/kernel/KernelKit | |
| parent | 3978ac0540a7e430a4a2a157d2e53653b5c37bd0 (diff) | |
fix: sem: fix decrement logic of the semaphore api's 'rtl_sem_wait'
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/kernel/KernelKit')
| -rw-r--r-- | dev/kernel/KernelKit/Semaphore.h | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/dev/kernel/KernelKit/Semaphore.h b/dev/kernel/KernelKit/Semaphore.h index 686ce1c9..618a3268 100644 --- a/dev/kernel/KernelKit/Semaphore.h +++ b/dev/kernel/KernelKit/Semaphore.h @@ -67,11 +67,6 @@ inline BOOL rtl_sem_wait(Semaphore& sem, UInt64 owner, UInt64 timeout, BOOL* con return FALSE; } - if (sem[kSemaphoreCountIndex] <= 0) { - err_global_get() = kErrorNetworkTimeout; - return FALSE; - } - if (timeout <= 0) { err_global_get() = kErrorNetworkTimeout; @@ -79,6 +74,11 @@ inline BOOL rtl_sem_wait(Semaphore& sem, UInt64 owner, UInt64 timeout, BOOL* con } if (!condition || *condition) { + if (sem[kSemaphoreCountIndex] == 0) { + err_global_get() = kErrorNetworkTimeout; + return FALSE; + } + err_global_get() = kErrorSuccess; sem[kSemaphoreCountIndex]--; @@ -90,6 +90,11 @@ inline BOOL rtl_sem_wait(Semaphore& sem, UInt64 owner, UInt64 timeout, BOOL* con if (ret) { if (!condition || *condition) { + if (sem[kSemaphoreCountIndex] == 0) { + err_global_get() = kErrorNetworkTimeout; + return FALSE; + } + err_global_get() = kErrorSuccess; sem[kSemaphoreCountIndex]--; |
