unix, win: consolidate mutex trylock errors
Fold EAGAIN into EBUSY, and make it the only acceptable error. PR-URL: https://github.com/libuv/libuv/pull/535 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
parent
85adf43e03
commit
bd1777fd53
@ -124,14 +124,14 @@ void uv_mutex_lock(uv_mutex_t* mutex) {
|
||||
int uv_mutex_trylock(uv_mutex_t* mutex) {
|
||||
int err;
|
||||
|
||||
/* FIXME(bnoordhuis) EAGAIN means recursive lock limit reached. Arguably
|
||||
* a bug, should probably abort rather than return -EAGAIN.
|
||||
*/
|
||||
err = pthread_mutex_trylock(mutex);
|
||||
if (err && err != EBUSY && err != EAGAIN)
|
||||
abort();
|
||||
if (err) {
|
||||
if (err != EBUSY && err != EAGAIN)
|
||||
abort();
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
return -err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -232,7 +232,7 @@ int uv_mutex_trylock(uv_mutex_t* mutex) {
|
||||
if (TryEnterCriticalSection(mutex))
|
||||
return 0;
|
||||
else
|
||||
return UV_EAGAIN;
|
||||
return UV_EBUSY;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user