mdbx: simplify check_txn_rw().

Change-Id: Id6a24068ffcdd29fe15a888985bd4a17f1de8ab4
This commit is contained in:
Leonid Yuriev 2021-03-14 16:33:06 +03:00
parent f2d2a4c698
commit 3eb343020d

View File

@ -7204,39 +7204,26 @@ static __always_inline int check_txn(const MDBX_txn *txn, int bad_bits) {
if (unlikely(txn->mt_flags & bad_bits)) if (unlikely(txn->mt_flags & bad_bits))
return MDBX_BAD_TXN; return MDBX_BAD_TXN;
if (unlikely(!txn->mt_env->me_map))
return MDBX_EPERM;
#if MDBX_TXN_CHECKOWNER #if MDBX_TXN_CHECKOWNER
if ((txn->mt_flags & MDBX_NOTLS) == 0 && if ((txn->mt_flags & MDBX_NOTLS) == 0 &&
unlikely(txn->mt_owner != mdbx_thread_self())) unlikely(txn->mt_owner != mdbx_thread_self()))
return txn->mt_owner ? MDBX_THREAD_MISMATCH : MDBX_BAD_TXN; return txn->mt_owner ? MDBX_THREAD_MISMATCH : MDBX_BAD_TXN;
#endif /* MDBX_TXN_CHECKOWNER */ #endif /* MDBX_TXN_CHECKOWNER */
if (unlikely(!txn->mt_env->me_map))
return MDBX_EPERM;
return MDBX_SUCCESS; return MDBX_SUCCESS;
} }
static __always_inline int check_txn_rw(const MDBX_txn *txn, int bad_bits) { static __always_inline int check_txn_rw(const MDBX_txn *txn, int bad_bits) {
if (unlikely(!txn)) int err = check_txn(txn, bad_bits);
return MDBX_EINVAL; if (unlikely(err))
return err;
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;
if (unlikely(F_ISSET(txn->mt_flags, MDBX_TXN_RDONLY))) if (unlikely(F_ISSET(txn->mt_flags, MDBX_TXN_RDONLY)))
return MDBX_EACCESS; 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; return MDBX_SUCCESS;
} }