From 5e1721efdd26936c0b9c37aa7a4b5edfd41e77db Mon Sep 17 00:00:00 2001 From: Leo Yuriev Date: Thu, 26 Oct 2017 21:22:25 +0300 Subject: [PATCH] mdbx: fix mdbx_robust_trylock(). --- src/lck-posix.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/lck-posix.c b/src/lck-posix.c index 0c8cb41b..2aeed6f4 100644 --- a/src/lck-posix.c +++ b/src/lck-posix.c @@ -1,4 +1,4 @@ -/* +/* * Copyright 2015-2017 Leonid Yuriev * and other libmdbx authors: please see AUTHORS file. * All rights reserved. @@ -186,9 +186,9 @@ static int mdbx_robust_lock(MDBX_env *env, pthread_mutex_t *mutex) { static int mdbx_robust_trylock(MDBX_env *env, pthread_mutex_t *mutex) { int rc = pthread_mutex_trylock(mutex); - if (unlikely(rc != 0)) + if (unlikely(rc != 0 && rc != EBUSY)) rc = mdbx_mutex_failed(env, mutex, rc); - return rc; + return (rc != EBUSY) ? rc : MDBX_BUSY; } static int mdbx_robust_unlock(MDBX_env *env, pthread_mutex_t *mutex) { @@ -327,9 +327,7 @@ static int __cold mdbx_mutex_failed(MDBX_env *env, pthread_mutex_t *mutex, #endif /* MDBX_USE_ROBUST */ mdbx_error("mutex (un)lock failed, %s", mdbx_strerror(rc)); - if (rc == EBUSY) { - rc = MDBX_BUSY; - } else if (rc != EDEADLK && rc != EBUSY) { + if (rc != EDEADLK) { env->me_flags |= MDBX_FATAL_ERROR; rc = MDBX_PANIC; }