]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: adjust lmdb usage for shared_ptr
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Fri, 15 Nov 2019 15:50:42 +0000 (16:50 +0100)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Fri, 15 Nov 2019 15:50:42 +0000 (16:50 +0100)
pdns/dnsdistdist/dnsdist-kvs.cc
pdns/dnsdistdist/test-dnsdistkvs_cc.cc

index a99047ffaac0c3b8403718c6af3aadd7e7f8f084..67976d9c98ee3676bc9f1b7efaf85a60d885f211 100644 (file)
@@ -74,9 +74,9 @@ bool LMDBKVStore::getValue(const std::string& key, std::string& value)
 {
   try {
     auto transaction = d_env.getROTransaction();
-    auto dbi = transaction.openDB(d_dbName, 0);
+    auto dbi = transaction->openDB(d_dbName, 0);
     MDBOutVal result;
-    int rc = transaction.get(dbi, MDBInVal(key), result);
+    int rc = transaction->get(dbi, MDBInVal(key), result);
     if (rc == 0) {
       value = result.get<std::string>();
       return true;
@@ -95,9 +95,9 @@ bool LMDBKVStore::keyExists(const std::string& key)
 {
   try {
     auto transaction = d_env.getROTransaction();
-    auto dbi = transaction.openDB(d_dbName, 0);
+    auto dbi = transaction->openDB(d_dbName, 0);
     MDBOutVal result;
-    int rc = transaction.get(dbi, MDBInVal(key), result);
+    int rc = transaction->get(dbi, MDBInVal(key), result);
     if (rc == 0) {
       return true;
     }
index 5261f0232689c8760499d4d77078d6147009a5d5..757d14a349f02b744f2d17900d274e0ee0eb9f17 100644 (file)
@@ -224,11 +224,11 @@ BOOST_AUTO_TEST_CASE(test_LMDB) {
   {
     MDBEnv env(dbPath.c_str(), MDB_NOSUBDIR, 0600);
     auto transaction = env.getRWTransaction();
-    auto dbi = transaction.openDB("db-name", MDB_CREATE);
-    transaction.put(dbi, MDBInVal(std::string(reinterpret_cast<const char*>(&rem.sin4.sin_addr.s_addr), sizeof(rem.sin4.sin_addr.s_addr))), MDBInVal("this is the value for the remote addr"));
-    transaction.put(dbi, MDBInVal(qname.toDNSStringLC()), MDBInVal("this is the value for the qname"));
-    transaction.put(dbi, MDBInVal(plaintextDomain.toStringRootDot()), MDBInVal("this is the value for the plaintext domain"));
-    transaction.commit();
+    auto dbi = transaction->openDB("db-name", MDB_CREATE);
+    transaction->put(dbi, MDBInVal(std::string(reinterpret_cast<const char*>(&rem.sin4.sin_addr.s_addr), sizeof(rem.sin4.sin_addr.s_addr))), MDBInVal("this is the value for the remote addr"));
+    transaction->put(dbi, MDBInVal(qname.toDNSStringLC()), MDBInVal("this is the value for the qname"));
+    transaction->put(dbi, MDBInVal(plaintextDomain.toStringRootDot()), MDBInVal("this is the value for the plaintext domain"));
+    transaction->commit();
   }
 
   auto lmdb = std::unique_ptr<KeyValueStore>(new LMDBKVStore(dbPath, "db-name"));