From: Peter van Dijk Date: Fri, 15 Nov 2019 15:50:42 +0000 (+0100) Subject: dnsdist: adjust lmdb usage for shared_ptr X-Git-Tag: auth-4.3.0-alpha1~38^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d76cdfe977f801b66be7702f87606e9e0b268071;p=thirdparty%2Fpdns.git dnsdist: adjust lmdb usage for shared_ptr --- diff --git a/pdns/dnsdistdist/dnsdist-kvs.cc b/pdns/dnsdistdist/dnsdist-kvs.cc index a99047ffaa..67976d9c98 100644 --- a/pdns/dnsdistdist/dnsdist-kvs.cc +++ b/pdns/dnsdistdist/dnsdist-kvs.cc @@ -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(); 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; } diff --git a/pdns/dnsdistdist/test-dnsdistkvs_cc.cc b/pdns/dnsdistdist/test-dnsdistkvs_cc.cc index 5261f02326..757d14a349 100644 --- a/pdns/dnsdistdist/test-dnsdistkvs_cc.cc +++ b/pdns/dnsdistdist/test-dnsdistkvs_cc.cc @@ -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(&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(&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(new LMDBKVStore(dbPath, "db-name"));