]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Fix KVS compilation on Boost < 1.56 8248/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 29 Aug 2019 09:48:26 +0000 (11:48 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 29 Aug 2019 10:14:20 +0000 (12:14 +0200)
When neither the C++ 17 nor Boost >= 1.61 string_view are available,
we fall back to boost::string_ref. Unfortunately it didn't have the
to_string() method before 1.56.
Since we end up converting it to a string anyway, let's just skip the
string_view/string_ref part.

pdns/dnsdistdist/dnsdist-kvs.cc

index 814551bfec3734a970de667fff0bcd9d1d35a1fd..a99047ffaac0c3b8403718c6af3aadd7e7f8f084 100644 (file)
@@ -72,13 +72,13 @@ std::vector<std::string> KeyValueLookupKeySuffix::getKeys(const DNSName& qname)
 
 bool LMDBKVStore::getValue(const std::string& key, std::string& value)
 {
-  string_view result;
   try {
     auto transaction = d_env.getROTransaction();
     auto dbi = transaction.openDB(d_dbName, 0);
+    MDBOutVal result;
     int rc = transaction.get(dbi, MDBInVal(key), result);
     if (rc == 0) {
-      value = result.to_string();
+      value = result.get<std::string>();
       return true;
     }
     else if (rc == MDB_NOTFOUND) {
@@ -93,10 +93,10 @@ bool LMDBKVStore::getValue(const std::string& key, std::string& value)
 
 bool LMDBKVStore::keyExists(const std::string& key)
 {
-  string_view result;
   try {
     auto transaction = d_env.getROTransaction();
     auto dbi = transaction.openDB(d_dbName, 0);
+    MDBOutVal result;
     int rc = transaction.get(dbi, MDBInVal(key), result);
     if (rc == 0) {
       return true;