From 17bf75b12eb94d9903cd62329048b146d5313bad Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Sat, 22 Nov 2014 22:56:31 +0100 Subject: [PATCH] ITS#7961,#7987 Re-fix txn init. More fallout from 4d02c741b120786df1b87ee9ed49c1d3f9bc7522: Don't modify another thread's write txn. Reinit me_txn0 fully. --- libraries/liblmdb/mdb.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 2e9e3dc96e..d4edda47bc 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -2542,6 +2542,10 @@ mdb_txn_renew0(MDB_txn *txn) 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; @@ -2627,7 +2631,6 @@ mdb_txn_begin(MDB_env *env, MDB_txn *parent, unsigned int flags, MDB_txn **ret) 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 */ @@ -2778,6 +2781,8 @@ mdb_txn_reset0(MDB_txn *txn, const char *act) env->me_pghead = NULL; env->me_pglast = 0; + mdb_cursors_close(txn, 0); + if (!(env->me_flags & MDB_WRITEMAP)) { mdb_dlist_free(txn); } @@ -2790,19 +2795,15 @@ mdb_txn_reset0(MDB_txn *txn, const char *act) /* The writer mutex was locked in mdb_txn_begin. */ if (env->me_txns) UNLOCK_MUTEX_W(env); - } - - 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); } } -- 2.39.5