summaryrefslogtreecommitdiff
path: root/pthread_cond_signal.c
diff options
context:
space:
mode:
Diffstat (limited to 'pthread_cond_signal.c')
-rw-r--r--pthread_cond_signal.c96
1 files changed, 48 insertions, 48 deletions
diff --git a/pthread_cond_signal.c b/pthread_cond_signal.c
index 156c0d0..84ace67 100644
--- a/pthread_cond_signal.c
+++ b/pthread_cond_signal.c
@@ -167,8 +167,7 @@
static INLINE int
-ptw32_cond_unblock (pthread_cond_t * cond,
- int unblockAll)
+ptw32_cond_unblock (pthread_cond_t * cond, int unblockAll)
/*
* Notes.
*
@@ -209,69 +208,70 @@ ptw32_cond_unblock (pthread_cond_t * cond,
return 0;
}
- if ((result = pthread_mutex_lock(&(cv->mtxUnblockLock))) != 0)
+ if ((result = pthread_mutex_lock (&(cv->mtxUnblockLock))) != 0)
{
return result;
}
- if ( 0 != cv->nWaitersToUnblock )
+ if (0 != cv->nWaitersToUnblock)
{
- if ( 0 == cv->nWaitersBlocked )
- {
- return pthread_mutex_unlock( &(cv->mtxUnblockLock) );
- }
+ if (0 == cv->nWaitersBlocked)
+ {
+ return pthread_mutex_unlock (&(cv->mtxUnblockLock));
+ }
if (unblockAll)
- {
- cv->nWaitersToUnblock += (nSignalsToIssue = cv->nWaitersBlocked);
- cv->nWaitersBlocked = 0;
- }
+ {
+ cv->nWaitersToUnblock += (nSignalsToIssue = cv->nWaitersBlocked);
+ cv->nWaitersBlocked = 0;
+ }
else
- {
- nSignalsToIssue = 1;
- cv->nWaitersToUnblock++;
- cv->nWaitersBlocked--;
- }
+ {
+ nSignalsToIssue = 1;
+ cv->nWaitersToUnblock++;
+ cv->nWaitersBlocked--;
+ }
}
- else if ( cv->nWaitersBlocked > cv->nWaitersGone )
+ else if (cv->nWaitersBlocked > cv->nWaitersGone)
{
- if (sem_wait( &(cv->semBlockLock) ) != 0)
- {
- result = errno;
- (void) pthread_mutex_unlock( &(cv->mtxUnblockLock) );
- return result;
- }
- if ( 0 != cv->nWaitersGone )
- {
- cv->nWaitersBlocked -= cv->nWaitersGone;
- cv->nWaitersGone = 0;
- }
+ /* Use the non-cancellable version of sem_wait() */
+ if (ptw32_semwait (&(cv->semBlockLock)) != 0)
+ {
+ result = errno;
+ (void) pthread_mutex_unlock (&(cv->mtxUnblockLock));
+ return result;
+ }
+ if (0 != cv->nWaitersGone)
+ {
+ cv->nWaitersBlocked -= cv->nWaitersGone;
+ cv->nWaitersGone = 0;
+ }
if (unblockAll)
- {
- nSignalsToIssue = cv->nWaitersToUnblock = cv->nWaitersBlocked;
- cv->nWaitersBlocked = 0;
- }
+ {
+ nSignalsToIssue = cv->nWaitersToUnblock = cv->nWaitersBlocked;
+ cv->nWaitersBlocked = 0;
+ }
else
- {
- nSignalsToIssue = cv->nWaitersToUnblock = 1;
- cv->nWaitersBlocked--;
- }
+ {
+ nSignalsToIssue = cv->nWaitersToUnblock = 1;
+ cv->nWaitersBlocked--;
+ }
}
else
{
- return pthread_mutex_unlock( &(cv->mtxUnblockLock) );
+ return pthread_mutex_unlock (&(cv->mtxUnblockLock));
}
- if ((result = pthread_mutex_unlock( &(cv->mtxUnblockLock) )) == 0)
+ if ((result = pthread_mutex_unlock (&(cv->mtxUnblockLock))) == 0)
{
- if (sem_post_multiple( &(cv->semBlockQueue), nSignalsToIssue ) != 0)
- {
- result = errno;
- }
+ if (sem_post_multiple (&(cv->semBlockQueue), nSignalsToIssue) != 0)
+ {
+ result = errno;
+ }
}
return result;
-} /* ptw32_cond_unblock */
+} /* ptw32_cond_unblock */
int
pthread_cond_signal (pthread_cond_t * cond)
@@ -311,9 +311,9 @@ pthread_cond_signal (pthread_cond_t * cond)
/*
* The '0'(FALSE) unblockAll arg means unblock ONE waiter.
*/
- return (ptw32_cond_unblock(cond, 0));
+ return (ptw32_cond_unblock (cond, 0));
-} /* pthread_cond_signal */
+} /* pthread_cond_signal */
int
pthread_cond_broadcast (pthread_cond_t * cond)
@@ -350,6 +350,6 @@ pthread_cond_broadcast (pthread_cond_t * cond)
/*
* The TRUE unblockAll arg means unblock ALL waiters.
*/
- return (ptw32_cond_unblock(cond, PTW32_TRUE));
+ return (ptw32_cond_unblock (cond, PTW32_TRUE));
-} /* pthread_cond_broadcast */
+} /* pthread_cond_broadcast */