From 54920cd07bc42395ebf6ef8db0a727ae1a2ff893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Tue, 31 Oct 2023 12:11:59 +0300 Subject: [PATCH] =?UTF-8?q?mdbx:=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20assert-=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D0=BE=D0=BA=20=D0=B2=D0=BD=D1=83=D1=82=D1=80?= =?UTF-8?q?=D0=B8=20`osal=5Ftxn=5Flock()`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lck-posix.c | 5 ++++- src/lck-windows.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lck-posix.c b/src/lck-posix.c index 7f58e9ed..d55a9395 100644 --- a/src/lck-posix.c +++ b/src/lck-posix.c @@ -956,11 +956,14 @@ MDBX_INTERNAL_FUNC void osal_rdt_unlock(MDBX_env *env) { int osal_txn_lock(MDBX_env *env, bool dont_wait) { TRACE("%swait %s", dont_wait ? "dont-" : "", ">>"); - eASSERT(env, !env->me_txn0->mt_owner); jitter4testing(true); const int err = mdbx_ipclock_lock(env, &env->me_lck->mti_wlock, dont_wait); int rc = err; if (likely(!MDBX_IS_ERROR(err))) { + eASSERT(env, !env->me_txn0->mt_owner || + err == /* если другой поток в этом-же процессе завершился + не освободив блокировку */ + MDBX_RESULT_TRUE); env->me_txn0->mt_owner = osal_thread_self(); rc = MDBX_SUCCESS; } diff --git a/src/lck-windows.c b/src/lck-windows.c index ed77da30..d2354285 100644 --- a/src/lck-windows.c +++ b/src/lck-windows.c @@ -179,7 +179,6 @@ static int funlock(mdbx_filehandle_t fd, size_t offset, size_t bytes) { #define DXB_WHOLE 0, DXB_MAXLEN int osal_txn_lock(MDBX_env *env, bool dontwait) { - eASSERT(env, !env->me_txn0->mt_owner); if (dontwait) { if (!TryEnterCriticalSection(&env->me_windowsbug_lock)) return MDBX_BUSY; @@ -195,6 +194,7 @@ int osal_txn_lock(MDBX_env *env, bool dontwait) { } } + eASSERT(env, !env->me_txn0->mt_owner); if (env->me_flags & MDBX_EXCLUSIVE) goto done;