diff options
-rw-r--r-- | lib/libc/gen/sem.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/lib/libc/gen/sem.c b/lib/libc/gen/sem.c index 34ea8f7..ec80bc3 100644 --- a/lib/libc/gen/sem.c +++ b/lib/libc/gen/sem.c @@ -304,14 +304,13 @@ __sem_trywait(sem_t *sem) retval = ksem_trywait((*sem)->semid); else { _pthread_mutex_lock(&(*sem)->lock); - if ((*sem)->count != 0) { + if ((*sem)->count > 0) { (*sem)->count--; retval = 0; } else { errno = EAGAIN; retval = -1; } - (*sem)->count--; _pthread_mutex_unlock(&(*sem)->lock); } return (retval); |