From 3eb343020d169057405cafcc00edee0e145ac49c Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Sun, 14 Mar 2021 16:33:06 +0300 Subject: [PATCH] mdbx: simplify `check_txn_rw()`. Change-Id: Id6a24068ffcdd29fe15a888985bd4a17f1de8ab4 --- src/core.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/src/core.c b/src/core.c index b45b8d36..74869f5e 100644 --- a/src/core.c +++ b/src/core.c @@ -7204,39 +7204,26 @@ static __always_inline int check_txn(const MDBX_txn *txn, int bad_bits) { if (unlikely(txn->mt_flags & bad_bits)) return MDBX_BAD_TXN; - if (unlikely(!txn->mt_env->me_map)) - return MDBX_EPERM; - #if MDBX_TXN_CHECKOWNER if ((txn->mt_flags & MDBX_NOTLS) == 0 && unlikely(txn->mt_owner != mdbx_thread_self())) return txn->mt_owner ? MDBX_THREAD_MISMATCH : MDBX_BAD_TXN; #endif /* MDBX_TXN_CHECKOWNER */ + if (unlikely(!txn->mt_env->me_map)) + return MDBX_EPERM; + return MDBX_SUCCESS; } static __always_inline int check_txn_rw(const MDBX_txn *txn, int bad_bits) { - if (unlikely(!txn)) - return MDBX_EINVAL; - - if (unlikely(txn->mt_signature != MDBX_MT_SIGNATURE)) - return MDBX_EBADSIGN; - - if (unlikely(txn->mt_flags & bad_bits)) - return MDBX_BAD_TXN; - - if (unlikely(!txn->mt_env->me_map)) - return MDBX_EPERM; + int err = check_txn(txn, bad_bits); + if (unlikely(err)) + return err; if (unlikely(F_ISSET(txn->mt_flags, MDBX_TXN_RDONLY))) return MDBX_EACCESS; -#if MDBX_TXN_CHECKOWNER - if (unlikely(txn->mt_owner != mdbx_thread_self())) - return txn->mt_owner ? MDBX_THREAD_MISMATCH : MDBX_BAD_TXN; -#endif /* MDBX_TXN_CHECKOWNER */ - return MDBX_SUCCESS; }