aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db
diff options
context:
space:
mode:
authorwarptangent <warptangent@tutanota.com>2016-02-13 03:50:42 -0800
committerwarptangent <warptangent@tutanota.com>2016-02-13 04:17:37 -0800
commitc16cc204d320fb61a462397644ec35c04286182a (patch)
tree73a7df5e6efda8836ae3db437d1ec0ebcc7b4114 /src/blockchain_db
parentBlockchainLMDB: Call destructor on allocated txn if setup fails (diff)
downloadmonero-c16cc204d320fb61a462397644ec35c04286182a.tar.xz
BlockchainLMDB: Add sanity check for inconsistent state
This hasn't been known to occur in block-level txn abort, but throw exception if it does.
Diffstat (limited to 'src/blockchain_db')
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp
index 3b3c5691b..7b7af23b9 100644
--- a/src/blockchain_db/lmdb/db_lmdb.cpp
+++ b/src/blockchain_db/lmdb/db_lmdb.cpp
@@ -2233,8 +2233,19 @@ void BlockchainLMDB::block_txn_abort()
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
if (! m_batch_active)
{
- delete m_write_txn;
- m_write_txn = nullptr;
+ if (m_write_txn != nullptr)
+ {
+ delete m_write_txn;
+ m_write_txn = nullptr;
+ }
+ else
+ {
+ // This would probably mean an earlier exception was caught, but then we
+ // proceeded further than we should have.
+ throw0(DB_ERROR((std::string("BlockchainLMDB::") + __func__ +
+ std::string(": block-level DB transaction abort called when write txn doesn't exist")
+ ).c_str()));
+ }
}
}