diff options
author | davidxu <davidxu@FreeBSD.org> | 2004-12-18 13:43:16 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2004-12-18 13:43:16 +0000 |
commit | acc63fde9c1cf061de6595200eb4bbb036c8f881 (patch) | |
tree | dd9a2b3bfa3d3ae5fc89ab95942d4ff04b039036 /sys/kern/kern_umtx.c | |
parent | 395ea4c2e2af05ed29a6da44bc4a81c58dd7aafc (diff) | |
download | FreeBSD-src-acc63fde9c1cf061de6595200eb4bbb036c8f881.zip FreeBSD-src-acc63fde9c1cf061de6595200eb4bbb036c8f881.tar.gz |
1. msleep returns EWOULDBLOCK not ETIMEDOUT, use EWOULDBLOCK instead.
2. Eliminate a possible lock leak in timed wait loop.
Diffstat (limited to 'sys/kern/kern_umtx.c')
-rw-r--r-- | sys/kern/kern_umtx.c | 14 |
1 files changed, 6 insertions, 8 deletions
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; |