diff options
author | Thomas Winget <tewinget@gmail.com> | 2015-05-18 05:45:15 -0400 |
---|---|---|
committer | Thomas Winget <tewinget@gmail.com> | 2015-05-18 06:12:54 -0400 |
commit | b0d849e0a475d575cdb34c6b42119b4380e220e5 (patch) | |
tree | 904dcab5f454391fb93628bd785c2308a5f80419 /src/blockchain_db/lmdb/db_lmdb.cpp | |
parent | LMDB should now dynamically resize the mapsize (diff) | |
download | monero-b0d849e0a475d575cdb34c6b42119b4380e220e5.tar.xz |
null out batch txn pointer as needed (BlockchainLMDB)
Diffstat (limited to '')
-rw-r--r-- | src/blockchain_db/lmdb/db_lmdb.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index 9579697d9..93900a434 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -760,6 +760,7 @@ BlockchainLMDB::BlockchainLMDB(bool batch_transactions) m_batch_transactions = batch_transactions; m_write_txn = nullptr; + m_write_batch_txn = nullptr; m_batch_active = false; m_height = 0; } @@ -1791,10 +1792,8 @@ void BlockchainLMDB::batch_start() throw0(DB_ERROR("batch transaction attempted, but m_write_txn already in use")); check_open(); - if (m_write_batch_txn == nullptr) - { - m_write_batch_txn = new mdb_txn_safe(); - } + m_write_batch_txn = new mdb_txn_safe(); + // NOTE: need to make sure it's destroyed properly when done if (mdb_txn_begin(m_env, NULL, 0, *m_write_batch_txn)) throw0(DB_ERROR("Failed to create a transaction for the db")); @@ -1846,6 +1845,7 @@ void BlockchainLMDB::batch_stop() // for destruction of batch transaction m_write_txn = nullptr; delete m_write_batch_txn; + m_write_batch_txn = nullptr; m_batch_active = false; LOG_PRINT_L3("batch transaction: end"); } @@ -1863,6 +1863,7 @@ void BlockchainLMDB::batch_abort() // explicitly call in case mdb_env_close() (BlockchainLMDB::close()) called before BlockchainLMDB destructor called. m_write_batch_txn->abort(); m_batch_active = false; + m_write_batch_txn = nullptr; LOG_PRINT_L3("batch transaction: aborted"); } |