summaryrefslogtreecommitdiffstats
path: root/common/storage_lmdb.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-03-06 18:13:19 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-03-06 18:13:19 +0100
commitceac8bebf60025a4da0997a4d73de1328c04e97d (patch)
tree8c39eba9027d44d3c6efc7816b9603587817acba /common/storage_lmdb.cpp
parent279c3fd398546eb6ed8cfb950b040e47a36e6711 (diff)
downloadsink-ceac8bebf60025a4da0997a4d73de1328c04e97d.tar.gz
sink-ceac8bebf60025a4da0997a4d73de1328c04e97d.zip
Ensure we don't try to open db's that are not available to our
transaction.
Diffstat (limited to 'common/storage_lmdb.cpp')
-rw-r--r--common/storage_lmdb.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/common/storage_lmdb.cpp b/common/storage_lmdb.cpp
index ed385ad..e49ecae 100644
--- a/common/storage_lmdb.cpp
+++ b/common/storage_lmdb.cpp
@@ -93,6 +93,18 @@ public:
93 const auto dbiName = name + db; 93 const auto dbiName = name + db;
94 if (sDbis.contains(dbiName)) { 94 if (sDbis.contains(dbiName)) {
95 dbi = sDbis.value(dbiName); 95 dbi = sDbis.value(dbiName);
96 //sDbis can contain dbi's that are not available to this transaction.
97 //We use mdb_dbi_flags to check if the dbi is valid for this transaction.
98 uint f;
99 if (mdb_dbi_flags(transaction, dbi, &f) == EINVAL) {
100 //In readonly mode we can just ignore this. In read-write we would have tried to concurrently create a db.
101 if (!readOnly) {
102 SinkWarning() << "Tried to create database in second transaction: " << dbiName;
103 }
104 dbi = 0;
105 transaction = 0;
106 return false;
107 }
96 } else { 108 } else {
97 MDB_dbi flagtableDbi; 109 MDB_dbi flagtableDbi;
98 if (const int rc = mdb_dbi_open(transaction, "__flagtable", readOnly ? 0 : MDB_CREATE, &flagtableDbi)) { 110 if (const int rc = mdb_dbi_open(transaction, "__flagtable", readOnly ? 0 : MDB_CREATE, &flagtableDbi)) {