diff options
author | jdp <jdp@FreeBSD.org> | 2004-06-14 18:19:05 +0000 |
---|---|---|
committer | jdp <jdp@FreeBSD.org> | 2004-06-14 18:19:05 +0000 |
commit | 32b926e0fbaacbc2b3175a2d2b1c791fbeefa99c (patch) | |
tree | f18a0b115d49023a3e78c267aa48ca58dc6304d5 /sys/kern | |
parent | f2c0db1521299639d6b16b7d477a777fbd81ada6 (diff) | |
download | FreeBSD-src-32b926e0fbaacbc2b3175a2d2b1c791fbeefa99c.zip FreeBSD-src-32b926e0fbaacbc2b3175a2d2b1c791fbeefa99c.tar.gz |
Change the return value of sema_timedwait() so it returns 0 on
success and a proper errno value on failure. This makes it
consistent with cv_timedwait(), and paves the way for the
introduction of functions such as sema_timedwait_sig() which can
fail in multiple ways.
Bump __FreeBSD_version and add a note to UPDATING.
Approved by: scottl (ips driver), arch
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_sema.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/sys/kern/kern_sema.c b/sys/kern/kern_sema.c index 0ee350a..f29aa88 100644 --- a/sys/kern/kern_sema.c +++ b/sys/kern/kern_sema.c @@ -108,7 +108,7 @@ _sema_wait(struct sema *sema, const char *file, int line) int _sema_timedwait(struct sema *sema, int timo, const char *file, int line) { - int ret, timed_out; + int error; mtx_lock(&sema->sema_mtx); @@ -118,27 +118,25 @@ _sema_timedwait(struct sema *sema, int timo, const char *file, int line) * continuously, since the timeout period is merely a lower bound on how * long to wait. */ - for (timed_out = 0; sema->sema_value == 0 && timed_out == 0;) { + for (error = 0; sema->sema_value == 0 && error == 0;) { sema->sema_waiters++; - timed_out = cv_timedwait(&sema->sema_cv, &sema->sema_mtx, timo); + error = cv_timedwait(&sema->sema_cv, &sema->sema_mtx, timo); sema->sema_waiters--; } if (sema->sema_value > 0) { /* Success. */ sema->sema_value--; - ret = 1; + error = 0; CTR6(KTR_LOCK, "%s(%p) \"%s\" v = %d at %s:%d", __func__, sema, cv_wmesg(&sema->sema_cv), sema->sema_value, file, line); } else { - ret = 0; - CTR5(KTR_LOCK, "%s(%p) \"%s\" fail at %s:%d", __func__, sema, cv_wmesg(&sema->sema_cv), file, line); } mtx_unlock(&sema->sema_mtx); - return (ret); + return (error); } int |