If a thread is resumed by thr_wake, it should return 0, especially it

should not return ERESTART after it caught a signal, otherwise
thr_wake() call will be lost, also a timeout wait should not be
restarted. Final, using wakeup not wakeup_one to be safeness.
This commit is contained in:
David Xu 2004-12-01 13:50:04 +00:00
parent 6fde64c778
commit c1df5a1a5d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=138272

View File

@ -264,11 +264,21 @@ thr_suspend(struct thread *td, struct thr_suspend_args *uap)
if ((td->td_flags & TDF_THRWAKEUP) == 0)
error = msleep((void *)td, &td->td_proc->p_mtx,
td->td_priority | PCATCH, "lthr", hz);
mtx_lock_spin(&sched_lock);
td->td_flags &= ~TDF_THRWAKEUP;
mtx_unlock_spin(&sched_lock);
if (td->td_flags & TDF_THRWAKEUP) {
mtx_lock_spin(&sched_lock);
td->td_flags &= ~TDF_THRWAKEUP;
mtx_unlock_spin(&sched_lock);
PROC_UNLOCK(td->td_proc);
return (0);
}
PROC_UNLOCK(td->td_proc);
return (error == EWOULDBLOCK ? ETIMEDOUT : error);
if (error == EWOULDBLOCK)
error = ETIMEDOUT;
else if (error == ERESTART) {
if (hz != 0)
error = EINTR;
}
return (error);
}
int
@ -289,7 +299,7 @@ thr_wake(struct thread *td, struct thr_wake_args *uap)
mtx_lock_spin(&sched_lock);
ttd->td_flags |= TDF_THRWAKEUP;
mtx_unlock_spin(&sched_lock);
wakeup_one((void *)ttd);
wakeup((void *)ttd);
PROC_UNLOCK(td->td_proc);
return (0);
}