diff options
-rw-r--r-- | condvar.c | 18 | ||||
-rw-r--r-- | semaphore.c | 6 |
2 files changed, 18 insertions, 6 deletions
@@ -728,7 +728,11 @@ ptw32_cond_wait_cleanup(void * args) if (sem_post( &(cv->semBlockLock) ) != 0) { *resultPtr = errno; - (void) pthread_mutex_unlock( &(cv->mtxUnblockLock) ); + /* + * This is a fatal error for this CV, + * so we deliberately don't unlock + * cv->mtxUnblockLock before returning. + */ return; } nSignalsWasLeft = 0; @@ -744,14 +748,22 @@ ptw32_cond_wait_cleanup(void * args) if (sem_wait( &(cv->semBlockLock) ) != 0) { *resultPtr = errno; - (void) pthread_mutex_unlock( &(cv->mtxUnblockLock) ); + /* + * This is a fatal error for this CV, + * so we deliberately don't unlock + * cv->mtxUnblockLock before returning. + */ return; } cv->nWaitersBlocked -= cv->nWaitersGone; if (sem_post( &(cv->semBlockLock) ) != 0) { *resultPtr = errno; - (void) pthread_mutex_unlock( &(cv->mtxUnblockLock) ); + /* + * This is a fatal error for this CV, + * so we deliberately don't unlock + * cv->mtxUnblockLock before returning. + */ return; } cv->nWaitersGone = 0; diff --git a/semaphore.c b/semaphore.c index ee9c8f6..f2210d4 100644 --- a/semaphore.c +++ b/semaphore.c @@ -475,7 +475,7 @@ sem_post_multiple (sem_t * sem, int count ) * pointer to an instance of sem_t * * count - * counter, must be greater than or equal to zero. + * counter, must be greater than zero. * * DESCRIPTION * This function posts multiple wakeups to a semaphore. If there @@ -487,14 +487,14 @@ sem_post_multiple (sem_t * sem, int count ) * -1 failed, error in errno * ERRNO * EINVAL 'sem' is not a valid semaphore - * or count is not greater than zero. + * or count is less than or equal to zero. * * ------------------------------------------------------ */ { int result = 0; - if (sem == NULL || *sem == NULL || count < 0) + if (sem == NULL || *sem == NULL || count <= 0) { result = EINVAL; } |