From bdc77df92148b3d0433a290df3ab72d0bffa554a Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Sun, 11 Aug 2019 00:07:21 +0300 Subject: [PATCH] mdbx: fix race-with-close for lck-posix. Change-Id: Ie601ebbec8cc47d26935e12a57abe991aec1cb41 --- src/lck-posix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lck-posix.c b/src/lck-posix.c index 8440c3fd..5bfb55b3 100644 --- a/src/lck-posix.c +++ b/src/lck-posix.c @@ -151,7 +151,7 @@ int __cold mdbx_lck_seize(MDBX_env *env) { OFF_T_MAX); if (rc == 0) { /* got dxb-exclusive, try lck-exclusive */ - rc = mdbx_lck_op(env->me_lfd, OP_SETLK, F_WRLCK, 0, OFF_T_MAX); + rc = mdbx_lck_op(env->me_lfd, OP_SETLKW, F_WRLCK, 0, OFF_T_MAX); if (rc == 0) { /* got both exclusive */ return MDBX_RESULT_TRUE; @@ -256,7 +256,7 @@ void __cold mdbx_lck_destroy(MDBX_env *env) { if (mdbx_lck_op(env->me_fd, OP_SETLK, (env->me_flags & MDBX_RDONLY) ? F_RDLCK : F_WRLCK, 0, OFF_T_MAX) == 0 && - mdbx_lck_op(env->me_lfd, OP_SETLK, F_WRLCK, 0, OFF_T_MAX) == 0) { + mdbx_lck_op(env->me_lfd, OP_SETLKW, F_WRLCK, 0, OFF_T_MAX) == 0) { mdbx_info("%s: got exclusive, drown mutexes", mdbx_func_); int rc = pthread_mutex_destroy(&env->me_lck->mti_rmutex); if (rc == 0)