if (txn->mt_txnid == mdb_debug_start)
mdb_debug = 1;
#endif
+ txn->mt_flags = 0;
+ txn->mt_child = NULL;
+ txn->mt_loose_pgs = NULL;
+ txn->mt_loose_count = 0;
txn->mt_dirty_room = MDB_IDL_UM_MAX;
txn->mt_u.dirty_list = env->me_dirty_list;
txn->mt_u.dirty_list[0].mid = 0;
if (!(flags & MDB_RDONLY)) {
if (!parent) {
txn = env->me_txn0; /* just reuse preallocated write txn */
- txn->mt_flags = 0;
goto ok;
}
/* child txns use own copy of cursors */
env->me_pghead = NULL;
env->me_pglast = 0;
+ mdb_cursors_close(txn, 0);
+
if (!(env->me_flags & MDB_WRITEMAP)) {
mdb_dlist_free(txn);
}
/* The writer mutex was locked in mdb_txn_begin. */
if (env->me_txns)
UNLOCK_MUTEX(MDB_MUTEX(env, w));
- }
-
- mdb_cursors_close(txn, 0);
-
- mdb_midl_free(pghead);
-
- if (txn->mt_parent) {
+ } else {
txn->mt_parent->mt_child = NULL;
env->me_pgstate = ((MDB_ntxn *)txn)->mnt_pgstate;
mdb_midl_free(txn->mt_free_pgs);
mdb_midl_free(txn->mt_spill_pgs);
free(txn->mt_u.dirty_list);
}
+
+ mdb_midl_free(pghead);
}
}