diff options
author | davidxu <davidxu@FreeBSD.org> | 2005-01-06 02:08:34 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2005-01-06 02:08:34 +0000 |
commit | a25b832d9a51c33f6aabaffe54292f7caa7aa11f (patch) | |
tree | a4b3e47e2ca530a06f5dbab74f9506c217769c76 /sys/kern/kern_umtx.c | |
parent | 4b319958e7f00cc908274c4518b7a9c5ed821812 (diff) | |
download | FreeBSD-src-a25b832d9a51c33f6aabaffe54292f7caa7aa11f.zip FreeBSD-src-a25b832d9a51c33f6aabaffe54292f7caa7aa11f.tar.gz |
Return ETIMEDOUT when thread is timeouted since POSIX thread
APIs expect ETIMEDOUT not EAGAIN, this simplifies userland code a
bit.
Diffstat (limited to 'sys/kern/kern_umtx.c')
-rw-r--r-- | sys/kern/kern_umtx.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c index 3c45ddc..c965a8c 100644 --- a/sys/kern/kern_umtx.c +++ b/sys/kern/kern_umtx.c @@ -282,8 +282,10 @@ umtxq_sleep(struct thread *td, struct umtx_key *key, int priority, const char *wmesg, int timo) { int chain = umtxq_hash(key); - - return (msleep(td, umtxq_mtx(chain), priority, wmesg, timo)); + int error = msleep(td, umtxq_mtx(chain), priority, wmesg, timo); + if (error == EWOULDBLOCK) + error = ETIMEDOUT; + return (error); } static int @@ -538,12 +540,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 = EWOULDBLOCK; + error = ETIMEDOUT; break; } timo = tvtohz(&tv); error = _do_lock(td, umtx, id, timo); - if (error != EWOULDBLOCK) + if (error != ETIMEDOUT) break; } } @@ -641,7 +643,7 @@ do_wait(struct thread *td, struct umtx *umtx, long id, struct timespec *abstime) TIMESPEC_TO_TIMEVAL(&tv, &ts1); umtxq_lock(&uq.uq_key); if (tv.tv_sec < 0) { - error = EWOULDBLOCK; + error = ETIMEDOUT; break; } timo = tvtohz(&tv); |