ITS#8157 mdb_txn_renew0(): init after error checks

mdb.RE/0.9
Hallvard Furuseth 10 years ago
parent 91743d66e6
commit 6bfadb9178
  1. 16
      libraries/liblmdb/mdb.c

@ -2498,15 +2498,11 @@ mdb_txn_renew0(MDB_txn *txn)
MDB_env *env = txn->mt_env; MDB_env *env = txn->mt_env;
MDB_txninfo *ti = env->me_txns; MDB_txninfo *ti = env->me_txns;
MDB_meta *meta; MDB_meta *meta;
unsigned int i, nr; unsigned int i, nr, flags = txn->mt_flags;
uint16_t x; uint16_t x;
int rc, new_notls = 0; int rc, new_notls = 0;
if (txn->mt_flags & MDB_TXN_RDONLY) { if ((flags &= MDB_TXN_RDONLY) != 0) {
txn->mt_flags = MDB_TXN_RDONLY;
/* Setup db info */
txn->mt_numdbs = env->me_numdbs;
txn->mt_dbxs = env->me_dbxs; /* mostly static anyway */
if (!ti) { if (!ti) {
meta = env->me_metas[ mdb_env_pick_meta(env) ]; meta = env->me_metas[ mdb_env_pick_meta(env) ];
txn->mt_txnid = meta->mm_txnid; txn->mt_txnid = meta->mm_txnid;
@ -2559,6 +2555,7 @@ mdb_txn_renew0(MDB_txn *txn)
txn->mt_u.reader = r; txn->mt_u.reader = r;
meta = env->me_metas[txn->mt_txnid & 1]; meta = env->me_metas[txn->mt_txnid & 1];
} }
txn->mt_dbxs = env->me_dbxs; /* mostly static anyway */
} else { } else {
if (ti) { if (ti) {
LOCK_MUTEX_W(env); LOCK_MUTEX_W(env);
@ -2569,14 +2566,11 @@ mdb_txn_renew0(MDB_txn *txn)
meta = env->me_metas[ mdb_env_pick_meta(env) ]; meta = env->me_metas[ mdb_env_pick_meta(env) ];
txn->mt_txnid = meta->mm_txnid; txn->mt_txnid = meta->mm_txnid;
} }
/* Setup db info */
txn->mt_numdbs = env->me_numdbs;
txn->mt_txnid++; txn->mt_txnid++;
#if MDB_DEBUG #if MDB_DEBUG
if (txn->mt_txnid == mdb_debug_start) if (txn->mt_txnid == mdb_debug_start)
mdb_debug = 1; mdb_debug = 1;
#endif #endif
txn->mt_flags = 0;
txn->mt_child = NULL; txn->mt_child = NULL;
txn->mt_loose_pgs = NULL; txn->mt_loose_pgs = NULL;
txn->mt_loose_count = 0; txn->mt_loose_count = 0;
@ -2596,6 +2590,10 @@ mdb_txn_renew0(MDB_txn *txn)
/* Moved to here to avoid a data race in read TXNs */ /* Moved to here to avoid a data race in read TXNs */
txn->mt_next_pgno = meta->mm_last_pg+1; txn->mt_next_pgno = meta->mm_last_pg+1;
txn->mt_flags = flags;
/* Setup db info */
txn->mt_numdbs = env->me_numdbs;
for (i=2; i<txn->mt_numdbs; i++) { for (i=2; i<txn->mt_numdbs; i++) {
x = env->me_dbflags[i]; x = env->me_dbflags[i];
txn->mt_dbs[i].md_flags = x & PERSISTENT_FLAGS; txn->mt_dbs[i].md_flags = x & PERSISTENT_FLAGS;

Loading…
Cancel
Save