diff options
author | jhb <jhb@FreeBSD.org> | 2001-06-22 23:06:38 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2001-06-22 23:06:38 +0000 |
commit | ae99243f0ba1da1338ce824ac163d44fe01b7967 (patch) | |
tree | 14f0fa8f510444d8e3bdfc61087dda07d7223674 | |
parent | e5e16e09ad14c1fc1ed934f3146c5c544b03c8d0 (diff) | |
download | FreeBSD-src-ae99243f0ba1da1338ce824ac163d44fe01b7967.zip FreeBSD-src-ae99243f0ba1da1338ce824ac163d44fe01b7967.tar.gz |
- Lock CURSIG with the proc lock and don't release the proc lock until
after grabbing the sched lock to close a race.
- Lock ktrace points with Giant.
-rw-r--r-- | sys/kern/kern_condvar.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sys/kern/kern_condvar.c b/sys/kern/kern_condvar.c index 1087fc6..07ed3b7 100644 --- a/sys/kern/kern_condvar.c +++ b/sys/kern/kern_condvar.c @@ -140,8 +140,10 @@ cv_switch_catch(struct proc *p) */ p->p_sflag |= PS_SINTR; mtx_unlock_spin(&sched_lock); + PROC_LOCK(p); sig = CURSIG(p); mtx_lock_spin(&sched_lock); + PROC_UNLOCK_NOSWITCH(p); if (sig != 0) { if (p->p_wchan != NULL) cv_waitq_remove(p); @@ -275,20 +277,22 @@ cv_wait_sig(struct cv *cvp, struct mtx *mp) mtx_unlock_spin(&sched_lock); PICKUP_GIANT(); + PROC_LOCK(p); if (sig == 0) sig = CURSIG(p); if (sig != 0) { - PROC_LOCK(p); if (SIGISMEMBER(p->p_sigacts->ps_sigintr, sig)) rval = EINTR; else rval = ERESTART; - PROC_UNLOCK(p); } + PROC_UNLOCK(p); #ifdef KTRACE + mtx_lock(&Giant); if (KTRPOINT(p, KTR_CSW)) ktrcsw(p->p_tracep, 0, 0); + mtx_unlock(&Giant); #endif mtx_lock(mp); WITNESS_RESTORE(&mp->mtx_object, mp); @@ -409,20 +413,22 @@ cv_timedwait_sig(struct cv *cvp, struct mtx *mp, int timo) mtx_unlock_spin(&sched_lock); PICKUP_GIANT(); + PROC_LOCK(p); if (sig == 0) sig = CURSIG(p); if (sig != 0) { - PROC_LOCK(p); if (SIGISMEMBER(p->p_sigacts->ps_sigintr, sig)) rval = EINTR; else rval = ERESTART; - PROC_UNLOCK(p); } + PROC_UNLOCK(p); #ifdef KTRACE + mtx_lock(&Giant); if (KTRPOINT(p, KTR_CSW)) ktrcsw(p->p_tracep, 0, 0); + mtx_unlock(&Giant); #endif mtx_lock(mp); WITNESS_RESTORE(&mp->mtx_object, mp); |