Return ETIMEDOUT when thread is timeouted since POSIX thread

APIs expect ETIMEDOUT not EAGAIN, this simplifies userland code a
bit.
This commit is contained in:
David Xu 2005-01-06 02:08:34 +00:00
parent 098ca2bda9
commit 476e1d077e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=139751

View File

@ -282,8 +282,10 @@ umtxq_sleep(struct thread *td, struct umtx_key *key, int priority,
const char *wmesg, int timo) const char *wmesg, int timo)
{ {
int chain = umtxq_hash(key); int chain = umtxq_hash(key);
int error = msleep(td, umtxq_mtx(chain), priority, wmesg, timo);
return (msleep(td, umtxq_mtx(chain), priority, wmesg, timo)); if (error == EWOULDBLOCK)
error = ETIMEDOUT;
return (error);
} }
static int static int
@ -538,12 +540,12 @@ do_lock(struct thread *td, struct umtx *umtx, long id,
timespecsub(&ts1, &ts2); timespecsub(&ts1, &ts2);
TIMESPEC_TO_TIMEVAL(&tv, &ts1); TIMESPEC_TO_TIMEVAL(&tv, &ts1);
if (tv.tv_sec < 0) { if (tv.tv_sec < 0) {
error = EWOULDBLOCK; error = ETIMEDOUT;
break; break;
} }
timo = tvtohz(&tv); timo = tvtohz(&tv);
error = _do_lock(td, umtx, id, timo); error = _do_lock(td, umtx, id, timo);
if (error != EWOULDBLOCK) if (error != ETIMEDOUT)
break; break;
} }
} }
@ -641,7 +643,7 @@ do_wait(struct thread *td, struct umtx *umtx, long id, struct timespec *abstime)
TIMESPEC_TO_TIMEVAL(&tv, &ts1); TIMESPEC_TO_TIMEVAL(&tv, &ts1);
umtxq_lock(&uq.uq_key); umtxq_lock(&uq.uq_key);
if (tv.tv_sec < 0) { if (tv.tv_sec < 0) {
error = EWOULDBLOCK; error = ETIMEDOUT;
break; break;
} }
timo = tvtohz(&tv); timo = tvtohz(&tv);