summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sig.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2003-04-18 20:59:05 +0000
committerjhb <jhb@FreeBSD.org>2003-04-18 20:59:05 +0000
commit801acfe1d4eb59bc3cb5449f681672d6712093a0 (patch)
tree42892c63b1dc99e6de1566799558fe413974fa5c /sys/kern/kern_sig.c
parent85d7526d963b421bd1c63ee5609e74174c02bbed (diff)
downloadFreeBSD-src-801acfe1d4eb59bc3cb5449f681672d6712093a0.zip
FreeBSD-src-801acfe1d4eb59bc3cb5449f681672d6712093a0.tar.gz
- Make sigonstack() a regular function instead of an inline and add a proc
lock assertion to it. - SIGPENDING() no longer needs sched_lock, so only grab sched_lock to set the TDF_NEEDSIGCHK and TDF_ASTPENDING flags in signotify(). - Add a proc lock assertion to tdsigwakeup(). - Since we always set TDF_OLDMASK while holding the proc lock, the proc lock is sufficient protection to check its state in postsig() and we only need sched_lock when clearing the actual flag.
Diffstat (limited to 'sys/kern/kern_sig.c')
-rw-r--r--sys/kern/kern_sig.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 5329992..e6a6e17 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -208,10 +208,27 @@ signotify(struct thread *td)
SIGSETNAND(p->p_siglist, set);
SIGSETOR(td->td_siglist, set);
- mtx_lock_spin(&sched_lock);
- if (SIGPENDING(td))
+ if (SIGPENDING(td)) {
+ mtx_lock_spin(&sched_lock);
td->td_flags |= TDF_NEEDSIGCHK | TDF_ASTPENDING;
- mtx_unlock_spin(&sched_lock);
+ mtx_unlock_spin(&sched_lock);
+ }
+}
+
+int
+sigonstack(size_t sp)
+{
+ struct proc *p = curthread->td_proc;
+
+ PROC_LOCK_ASSERT(p, MA_OWNED);
+ return ((p->p_flag & P_ALTSTACK) ?
+#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
+ ((p->p_sigstk.ss_size == 0) ? (p->p_sigstk.ss_flags & SS_ONSTACK) :
+ ((sp - (size_t)p->p_sigstk.ss_sp) < p->p_sigstk.ss_size))
+#else
+ ((sp - (size_t)p->p_sigstk.ss_sp) < p->p_sigstk.ss_size)
+#endif
+ : 0);
}
static __inline int
@@ -1809,6 +1826,7 @@ tdsigwakeup(struct thread *td, int sig, sig_t action)
struct proc *p = td->td_proc;
register int prop;
+ PROC_LOCK_ASSERT(p, MA_OWNED);
mtx_assert(&sched_lock, MA_OWNED);
prop = sigprop(sig);
/*
@@ -2144,13 +2162,13 @@ postsig(sig)
* mask from before the sigsuspend is what we want
* restored after the signal processing is completed.
*/
- mtx_lock_spin(&sched_lock);
if (td->td_flags & TDF_OLDMASK) {
returnmask = td->td_oldsigmask;
+ mtx_lock_spin(&sched_lock);
td->td_flags &= ~TDF_OLDMASK;
+ mtx_unlock_spin(&sched_lock);
} else
returnmask = td->td_sigmask;
- mtx_unlock_spin(&sched_lock);
SIGSETOR(td->td_sigmask, ps->ps_catchmask[_SIG_IDX(sig)]);
if (!SIGISMEMBER(ps->ps_signodefer, sig))
OpenPOWER on IntegriCloud