From da8501edf647f4cf6c4f86e95cb0a2c2a50bd7db Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Fri, 24 Jun 2016 02:04:55 +1000 Subject: [PATCH] deps: backport bd1777fd from libuv upstream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original commit message: 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 PR-URL: https://github.com/nodejs/node-private/pull/54 Reviewed-By: Saúl Ibarra Corretgé --- deps/uv/src/unix/thread.c | 12 ++++++------ deps/uv/src/win/thread.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/deps/uv/src/unix/thread.c b/deps/uv/src/unix/thread.c index 0c79827137acbe..c56a3170259e90 100644 --- a/deps/uv/src/unix/thread.c +++ b/deps/uv/src/unix/thread.c @@ -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; } diff --git a/deps/uv/src/win/thread.c b/deps/uv/src/win/thread.c index fd0873d603f799..51c4a671702b21 100644 --- a/deps/uv/src/win/thread.c +++ b/deps/uv/src/win/thread.c @@ -211,7 +211,7 @@ int uv_mutex_trylock(uv_mutex_t* mutex) { if (TryEnterCriticalSection(mutex)) return 0; else - return UV_EAGAIN; + return UV_EBUSY; }