mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-02 01:04:13 +08:00
lmdb: Cleanup, Drop !mt_dbxs hack, use MDB_TXN_FINISHED.
Change-Id: I23beaaf931c938ee9f3886ca1928ecbcd2fbe5ba
This commit is contained in:
parent
342d56977f
commit
11999c8c02
8
mdb.c
8
mdb.c
@ -2862,10 +2862,10 @@ mdb_txn_renew(MDB_txn *txn)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (!txn || txn->mt_dbxs) /* A reset txn has mt_dbxs==NULL */
|
||||
if (unlikely(!txn || !F_ISSET(txn->mt_flags, MDB_TXN_RDONLY|MDB_TXN_FINISHED)))
|
||||
return EINVAL;
|
||||
|
||||
if (txn->mt_env->me_flags & MDB_FATAL_ERROR) {
|
||||
if (unlikely(txn->mt_env->me_flags & MDB_FATAL_ERROR)) {
|
||||
mdb_debug("environment had fatal error, must shutdown!");
|
||||
return MDB_PANIC;
|
||||
}
|
||||
@ -2919,6 +2919,7 @@ mdb_txn_begin(MDB_env *env, MDB_txn *parent, unsigned flags, MDB_txn **ret)
|
||||
mdb_debug("calloc: %s", strerror(errno));
|
||||
return ENOMEM;
|
||||
}
|
||||
txn->mt_dbxs = env->me_dbxs; /* static */
|
||||
txn->mt_dbs = (MDB_db *) ((char *)txn + tsize);
|
||||
txn->mt_dbflags = (unsigned char *)txn + size - env->me_maxdbs;
|
||||
txn->mt_flags = flags;
|
||||
@ -2945,7 +2946,6 @@ mdb_txn_begin(MDB_env *env, MDB_txn *parent, unsigned flags, MDB_txn **ret)
|
||||
parent->mt_child = txn;
|
||||
txn->mt_parent = parent;
|
||||
txn->mt_numdbs = parent->mt_numdbs;
|
||||
txn->mt_dbxs = parent->mt_dbxs;
|
||||
memcpy(txn->mt_dbs, parent->mt_dbs, txn->mt_numdbs * sizeof(MDB_db));
|
||||
/* Copy parent's mt_dbflags, but clear DB_NEW */
|
||||
for (i=0; i<txn->mt_numdbs; i++)
|
||||
@ -3082,7 +3082,7 @@ mdb_txn_end(MDB_txn *txn, unsigned mode)
|
||||
mdb_coherent_barrier();
|
||||
txn->mt_numdbs = 0; /* prevent further DBI activity */
|
||||
txn->mt_flags |= MDB_TXN_FINISHED;
|
||||
txn->mt_dbxs = NULL; /* mark txn as reset */
|
||||
|
||||
} else if (!F_ISSET(txn->mt_flags, MDB_TXN_FINISHED)) {
|
||||
pgno_t *pghead = env->me_pghead;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user