aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2018-02-16 14:24:01 +0100
committerRiccardo Spagni <ric@spagni.net>2018-02-16 14:24:01 +0100
commit260d666cf45c0635f00fe6c3d23c79a27c8a8a4f (patch)
tree7a17847a8e2270bc8b602b1a84162c92db487539 /src
parentMerge pull request #3229 (diff)
parentDon't create readtxn until after txn_safe gate check (diff)
downloadmonero-260d666cf45c0635f00fe6c3d23c79a27c8a8a4f.tar.xz
Merge pull request #3231
84a8b2da Don't create readtxn until after txn_safe gate check (Howard Chu)
Diffstat (limited to 'src')
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp11
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.h1
2 files changed, 10 insertions, 2 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp
index 6b81a4c90..5210fc3cd 100644
--- a/src/blockchain_db/lmdb/db_lmdb.cpp
+++ b/src/blockchain_db/lmdb/db_lmdb.cpp
@@ -338,6 +338,12 @@ mdb_txn_safe::~mdb_txn_safe()
num_active_txns--;
}
+void mdb_txn_safe::uncheck()
+{
+ num_active_txns--;
+ m_check = false;
+}
+
void mdb_txn_safe::commit(std::string message)
{
if (message.size() == 0)
@@ -1439,9 +1445,10 @@ void BlockchainLMDB::unlock()
#define TXN_PREFIX_RDONLY() \
MDB_txn *m_txn; \
mdb_txn_cursors *m_cursors; \
+ mdb_txn_safe auto_txn; \
bool my_rtxn = block_rtxn_start(&m_txn, &m_cursors); \
- mdb_txn_safe auto_txn(my_rtxn); \
- if (my_rtxn) auto_txn.m_tinfo = m_tinfo.get()
+ if (my_rtxn) auto_txn.m_tinfo = m_tinfo.get(); \
+ else auto_txn.uncheck()
#define TXN_POSTFIX_RDONLY()
#define TXN_POSTFIX_SUCCESS() \
diff --git a/src/blockchain_db/lmdb/db_lmdb.h b/src/blockchain_db/lmdb/db_lmdb.h
index ceae2f084..1b76abf35 100644
--- a/src/blockchain_db/lmdb/db_lmdb.h
+++ b/src/blockchain_db/lmdb/db_lmdb.h
@@ -112,6 +112,7 @@ struct mdb_txn_safe
// BlockchainLMDB destructor to call mdb_txn_safe destructor, as that's too late
// to properly abort, since mdb_env_close would have been called earlier.
void abort();
+ void uncheck();
operator MDB_txn*()
{