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; }