mdbx: рефакторинг и вынос txn_abort() без кода входящих пероверок.

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2023-11-11 20:10:44 +03:00
parent 2fe01eee89
commit 1b2f5f25d4

View File

@ -10108,13 +10108,6 @@ static int txn_end(MDBX_txn *txn, const unsigned mode) {
MDBX_env *env = txn->mt_env; MDBX_env *env = txn->mt_env;
static const char *const names[] = TXN_END_NAMES; static const char *const names[] = TXN_END_NAMES;
#if MDBX_ENV_CHECKPID
if (unlikely(txn->mt_env->me_pid != osal_getpid())) {
env->me_flags |= MDBX_FATAL_ERROR;
return MDBX_PANIC;
}
#endif /* MDBX_ENV_CHECKPID */
DEBUG("%s txn %" PRIaTXN "%c %p on env %p, root page %" PRIaPGNO DEBUG("%s txn %" PRIaTXN "%c %p on env %p, root page %" PRIaPGNO
"/%" PRIaPGNO, "/%" PRIaPGNO,
names[mode & TXN_END_OPMASK], txn->mt_txnid, names[mode & TXN_END_OPMASK], txn->mt_txnid,
@ -10288,11 +10281,7 @@ int mdbx_txn_break(MDBX_txn *txn) {
return MDBX_SUCCESS; return MDBX_SUCCESS;
} }
int mdbx_txn_abort(MDBX_txn *txn) { static int txn_abort(MDBX_txn *txn) {
int rc = check_txn(txn, 0);
if (unlikely(rc != MDBX_SUCCESS))
return rc;
if (txn->mt_flags & MDBX_TXN_RDONLY) if (txn->mt_flags & MDBX_TXN_RDONLY)
/* LY: don't close DBI-handles */ /* LY: don't close DBI-handles */
return txn_end(txn, TXN_END_ABORT | TXN_END_UPDATE | TXN_END_SLOT | return txn_end(txn, TXN_END_ABORT | TXN_END_UPDATE | TXN_END_SLOT |
@ -10302,12 +10291,24 @@ int mdbx_txn_abort(MDBX_txn *txn) {
return MDBX_BAD_TXN; return MDBX_BAD_TXN;
if (txn->mt_child) if (txn->mt_child)
mdbx_txn_abort(txn->mt_child); txn_abort(txn->mt_child);
tASSERT(txn, (txn->mt_flags & MDBX_TXN_ERROR) || dirtylist_check(txn)); tASSERT(txn, (txn->mt_flags & MDBX_TXN_ERROR) || dirtylist_check(txn));
return txn_end(txn, TXN_END_ABORT | TXN_END_SLOT | TXN_END_FREE); return txn_end(txn, TXN_END_ABORT | TXN_END_SLOT | TXN_END_FREE);
} }
int mdbx_txn_abort(MDBX_txn *txn) {
int rc = check_txn(txn, 0);
if (unlikely(rc != MDBX_SUCCESS))
return rc;
rc = check_env(txn->mt_env, true);
if (unlikely(rc != MDBX_SUCCESS))
return rc;
return txn_abort(txn);
}
__cold static MDBX_db *audit_db_dig(const MDBX_txn *txn, const size_t dbi, __cold static MDBX_db *audit_db_dig(const MDBX_txn *txn, const size_t dbi,
MDBX_db *fallback) { MDBX_db *fallback) {
const MDBX_txn *dig = txn; const MDBX_txn *dig = txn;