summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-05 10:42:28 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-05 10:42:28 +0200
commit8eab2b67fdf83c657f996debfc238703a78b337b (patch)
treeaf23c674490c9e05c281ecd56b3e439f32229795
parent4bc39b1b771aaf9ae5f7c96aeaddb06f2bd101ac (diff)
downloadsink-8eab2b67fdf83c657f996debfc238703a78b337b.tar.gz
sink-8eab2b67fdf83c657f996debfc238703a78b337b.zip
Don't leak transactions when copying them.
Previsouly we would hit the maxreaders limit
-rw-r--r--common/storage_lmdb.cpp1
-rw-r--r--tests/storagetest.cpp18
2 files changed, 19 insertions, 0 deletions
diff --git a/common/storage_lmdb.cpp b/common/storage_lmdb.cpp
index e3685a5..cb7bca4 100644
--- a/common/storage_lmdb.cpp
+++ b/common/storage_lmdb.cpp
@@ -563,6 +563,7 @@ DataStore::Transaction::Transaction(Transaction &&other) : d(nullptr)
563DataStore::Transaction &DataStore::Transaction::operator=(DataStore::Transaction &&other) 563DataStore::Transaction &DataStore::Transaction::operator=(DataStore::Transaction &&other)
564{ 564{
565 if (&other != this) { 565 if (&other != this) {
566 abort();
566 delete d; 567 delete d;
567 d = other.d; 568 d = other.d;
568 other.d = nullptr; 569 other.d = nullptr;
diff --git a/tests/storagetest.cpp b/tests/storagetest.cpp
index 7202628..dfb91ec 100644
--- a/tests/storagetest.cpp
+++ b/tests/storagetest.cpp
@@ -487,6 +487,24 @@ private slots:
487 } 487 }
488 } 488 }
489 489
490 void testCopyTransaction()
491 {
492 Sink::Storage::DataStore store(testDataPath, dbName, Sink::Storage::DataStore::ReadWrite);
493 {
494 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadWrite);
495 transaction.openDatabase("a", nullptr, false);
496 transaction.openDatabase("b", nullptr, false);
497 transaction.openDatabase("c", nullptr, false);
498 transaction.commit();
499 }
500 auto transaction = store.createTransaction(Sink::Storage::DataStore::ReadOnly);
501 for (int i = 0; i < 1000; i++) {
502 transaction.openDatabase("a", nullptr, false);
503 transaction.openDatabase("b", nullptr, false);
504 transaction.openDatabase("c", nullptr, false);
505 transaction = store.createTransaction(Sink::Storage::DataStore::ReadOnly);
506 }
507 }
490}; 508};
491 509
492QTEST_MAIN(StorageTest) 510QTEST_MAIN(StorageTest)