From acc63fde9c1cf061de6595200eb4bbb036c8f881 Mon Sep 17 00:00:00 2001 From: davidxu Date: Sat, 18 Dec 2004 13:43:16 +0000 Subject: 1. msleep returns EWOULDBLOCK not ETIMEDOUT, use EWOULDBLOCK instead. 2. Eliminate a possible lock leak in timed wait loop. --- sys/kern/kern_umtx.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'sys') diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index a865d3a..94ec70d 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -525,12 +525,12 @@ do_lock(struct thread *td, struct umtx *umtx, long id, timespecsub(&ts1, &ts2); TIMESPEC_TO_TIMEVAL(&tv, &ts1); if (tv.tv_sec < 0) { - error = ETIMEDOUT; + error = EWOULDBLOCK; break; } timo = tvtohz(&tv); error = _do_lock(td, umtx, id, timo); - if (error != ETIMEDOUT) { + if (error != EWOULDBLOCK) { if (error == ERESTART) error = EINTR; break; @@ -689,22 +689,20 @@ do_unlock_and_wait(struct thread *td, struct umtx *umtx, long id, void *uaddr, timespecsub(&ts1, &ts2); TIMESPEC_TO_TIMEVAL(&tv, &ts1); if (tv.tv_sec < 0) { - error = ETIMEDOUT; + error = EWOULDBLOCK; break; } timo = tvtohz(&tv); umtxq_lock(&uq.uq_key); if (td->td_flags & TDF_UMTXQ) { error = umtxq_sleep(td, &uq.uq_key, - td->td_priority | PCATCH, - "ucond", timo); + td->td_priority | PCATCH | PDROP, + "ucond", timo); if (!(td->td_flags & TDF_UMTXQ)) { - umtxq_unlock(&uq.uq_key); error = 0; break; } - if (error != 0 && error != ETIMEDOUT) { - umtxq_unlock(&uq.uq_key); + if (error != 0 && error != EWOULDBLOCK) { if (error == ERESTART) error = EINTR; break; -- cgit v1.1