summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/thread/thr_sigwait.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libpthread/thread/thr_sigwait.c')
-rw-r--r--lib/libpthread/thread/thr_sigwait.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/lib/libpthread/thread/thr_sigwait.c b/lib/libpthread/thread/thr_sigwait.c
index 7b5a31f..9bb4285 100644
--- a/lib/libpthread/thread/thr_sigwait.c
+++ b/lib/libpthread/thread/thr_sigwait.c
@@ -49,7 +49,8 @@ _sigwait(const sigset_t *set, int *sig)
int i;
sigset_t tempset, waitset;
struct sigaction act;
-
+ kse_critical_t crit;
+
_thr_enter_cancellation_point(curthread);
/*
@@ -71,8 +72,11 @@ _sigwait(const sigset_t *set, int *sig)
/*
* Check to see if a pending signal is in the wait mask.
- * This has to be atomic. */
+ * This has to be atomic.
+ */
tempset = curthread->sigpend;
+ crit = _kse_critical_enter();
+ KSE_LOCK_ACQUIRE(curthread->kse, &_thread_signal_lock);
SIGSETOR(tempset, _thr_proc_sigpending);
SIGSETAND(tempset, waitset);
if (SIGNOTEMPTY(tempset)) {
@@ -83,24 +87,20 @@ _sigwait(const sigset_t *set, int *sig)
}
/* Clear the pending signal: */
- if (sigismember(&curthread->sigpend,i))
- sigdelset(&curthread->sigpend,i);
+ if (sigismember(&curthread->sigpend, i))
+ sigdelset(&curthread->sigpend, i);
else
- sigdelset(&_thr_proc_sigpending,i);
+ sigdelset(&_thr_proc_sigpending, i);
+ KSE_LOCK_RELEASE(curthread->kse, &_thread_signal_lock);
+ _kse_critical_leave(crit);
+ _thr_leave_cancellation_point(curthread);
/* Return the signal number to the caller: */
*sig = i;
-
- _thr_leave_cancellation_point(curthread);
return (0);
}
/*
- * Lock the array of SIG_DFL wait counts.
- */
- THR_LOCK_ACQUIRE(curthread, &_thread_signal_lock);
-
- /*
* Enter a loop to find the signals that are SIG_DFL. For
* these signals we must install a dummy signal handler in
* order for the kernel to pass them in to us. POSIX says
@@ -123,8 +123,8 @@ _sigwait(const sigset_t *set, int *sig)
}
}
/* Done accessing _thread_dfl_count for now. */
- THR_LOCK_RELEASE(curthread, &_thread_signal_lock);
-
+ KSE_LOCK_RELEASE(curthread->kse, &_thread_signal_lock);
+ _kse_critical_leave(crit);
if (ret == 0) {
/*
* Save the wait signal mask. The wait signal
@@ -151,7 +151,8 @@ _sigwait(const sigset_t *set, int *sig)
/*
* Relock the array of SIG_DFL wait counts.
*/
- THR_LOCK_ACQUIRE(curthread, &_thread_signal_lock);
+ crit = _kse_critical_enter();
+ KSE_LOCK_ACQUIRE(curthread->kse, &_thread_signal_lock);
/* Restore the sigactions: */
act.sa_handler = SIG_DFL;
@@ -166,10 +167,10 @@ _sigwait(const sigset_t *set, int *sig)
}
}
/* Done accessing _thread_dfl_count. */
- THR_LOCK_RELEASE(curthread, &_thread_signal_lock);
-
+ KSE_LOCK_RELEASE(curthread->kse, &_thread_signal_lock);
+ _kse_critical_leave(crit);
_thr_leave_cancellation_point(curthread);
-
+
/* Return the completion status: */
return (ret);
}
OpenPOWER on IntegriCloud