Index: kern_condvar.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_condvar.c,v retrieving revision 1.54 diff -u -u -r1.54 kern_condvar.c --- kern_condvar.c 15 Feb 2006 23:52:00 -0000 1.54 +++ kern_condvar.c 19 Feb 2006 04:30:56 -0000 @@ -192,18 +192,6 @@ sleepq_lock(cvp); - /* - * Don't bother sleeping if we are exiting and not the exiting - * thread or if our thread is marked as interrupted. - */ - mtx_lock_spin(&sched_lock); - rval = thread_sleep_check(td); - mtx_unlock_spin(&sched_lock); - if (rval != 0) { - sleepq_release(cvp); - return (rval); - } - cvp->cv_waiters++; DROP_GIANT(); mtx_unlock(mp); @@ -315,18 +303,6 @@ sleepq_lock(cvp); - /* - * Don't bother sleeping if we are exiting and not the exiting - * thread or if our thread is marked as interrupted. - */ - mtx_lock_spin(&sched_lock); - rval = thread_sleep_check(td); - mtx_unlock_spin(&sched_lock); - if (rval != 0) { - sleepq_release(cvp); - return (rval); - } - cvp->cv_waiters++; DROP_GIANT(); mtx_unlock(mp); Index: kern_synch.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_synch.c,v retrieving revision 1.276 diff -u -u -r1.276 kern_synch.c --- kern_synch.c 15 Feb 2006 23:52:00 -0000 1.276 +++ kern_synch.c 19 Feb 2006 04:31:11 -0000 @@ -164,22 +164,11 @@ if (TD_ON_SLEEPQ(td)) sleepq_remove(td, td->td_wchan); + flags = SLEEPQ_MSLEEP; + if (catch) + flags |= SLEEPQ_INTERRUPTIBLE; + sleepq_lock(ident); - if (catch) { - /* - * Don't bother sleeping if we are exiting and not the exiting - * thread or if our thread is marked as interrupted. - */ - mtx_lock_spin(&sched_lock); - rval = thread_sleep_check(td); - mtx_unlock_spin(&sched_lock); - if (rval != 0) { - sleepq_release(ident); - if (mtx != NULL && priority & PDROP) - mtx_unlock(mtx); - return (rval); - } - } CTR5(KTR_PROC, "msleep: thread %p (pid %ld, %s) on %s (%p)", (void *)td, (long)p->p_pid, p->p_comm, wmesg, ident); @@ -199,9 +188,6 @@ * stopped, then td will no longer be on a sleep queue upon * return from cursig(). */ - flags = SLEEPQ_MSLEEP; - if (catch) - flags |= SLEEPQ_INTERRUPTIBLE; sleepq_add(ident, mtx, wmesg, flags); if (timo) sleepq_set_timeout(ident, timo); Index: subr_sleepqueue.c =================================================================== RCS file: /home/ncvs/src/sys/kern/subr_sleepqueue.c,v retrieving revision 1.24 diff -u -u -r1.24 subr_sleepqueue.c --- subr_sleepqueue.c 15 Feb 2006 23:52:01 -0000 1.24 +++ subr_sleepqueue.c 19 Feb 2006 04:31:16 -0000 @@ -387,23 +387,29 @@ mtx_unlock(&ps->ps_mtx); } - if (ret) { + if (ret == 0) { + mtx_lock_spin(&sc->sc_lock); + mtx_lock_spin(&sched_lock); + PROC_UNLOCK(p); + if (!(td->td_flags & TDF_INTERRUPT)) + return (0); + /* KSE threads tried unblocking us. */ + ret = td->td_intrval; + mtx_unlock_spin(&sched_lock); + MPASS(ret == EINTR || ret == ERESTART); + } else { PROC_UNLOCK(p); /* * If there were pending signals and this thread is still on * the sleep queue, remove it from the sleep queue. */ mtx_lock_spin(&sc->sc_lock); - sq = sleepq_lookup(wchan); - mtx_lock_spin(&sched_lock); - if (TD_ON_SLEEPQ(td)) - sleepq_resume_thread(sq, td, -1); - td->td_flags &= ~TDF_SINTR; - } else { - mtx_lock_spin(&sc->sc_lock); - mtx_lock_spin(&sched_lock); - PROC_UNLOCK(p); } + sq = sleepq_lookup(wchan); + mtx_lock_spin(&sched_lock); + if (TD_ON_SLEEPQ(td)) + sleepq_resume_thread(sq, td, -1); + td->td_flags &= ~TDF_SINTR; return (ret); }