mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 17:14:12 +08:00
mdbx: fix mdbx_robust_trylock().
This commit is contained in:
parent
32c5c3b761
commit
5e1721efdd
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2017 Leonid Yuriev <leo@yuriev.ru>
|
* Copyright 2015-2017 Leonid Yuriev <leo@yuriev.ru>
|
||||||
* and other libmdbx authors: please see AUTHORS file.
|
* and other libmdbx authors: please see AUTHORS file.
|
||||||
* All rights reserved.
|
* 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) {
|
static int mdbx_robust_trylock(MDBX_env *env, pthread_mutex_t *mutex) {
|
||||||
int rc = pthread_mutex_trylock(mutex);
|
int rc = pthread_mutex_trylock(mutex);
|
||||||
if (unlikely(rc != 0))
|
if (unlikely(rc != 0 && rc != EBUSY))
|
||||||
rc = mdbx_mutex_failed(env, mutex, rc);
|
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) {
|
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 */
|
#endif /* MDBX_USE_ROBUST */
|
||||||
|
|
||||||
mdbx_error("mutex (un)lock failed, %s", mdbx_strerror(rc));
|
mdbx_error("mutex (un)lock failed, %s", mdbx_strerror(rc));
|
||||||
if (rc == EBUSY) {
|
if (rc != EDEADLK) {
|
||||||
rc = MDBX_BUSY;
|
|
||||||
} else if (rc != EDEADLK && rc != EBUSY) {
|
|
||||||
env->me_flags |= MDBX_FATAL_ERROR;
|
env->me_flags |= MDBX_FATAL_ERROR;
|
||||||
rc = MDBX_PANIC;
|
rc = MDBX_PANIC;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user