]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Follow suggestion by @rgacogne and specify the timestamp for 9639/head
authorOtto Moerbeek <otto@drijf.net>
Mon, 9 Nov 2020 10:50:53 +0000 (11:50 +0100)
committerOtto Moerbeek <otto@drijf.net>
Mon, 9 Nov 2020 10:50:53 +0000 (11:50 +0100)
converting ttd to ttl as an arg in the negCache dump.

pdns/rec_channel_rec.cc
pdns/recursordist/negcache.cc
pdns/recursordist/negcache.hh
pdns/recursordist/test-negcache_cc.cc

index a192962a232dbb22d99088987d5ab936632efb6c..c074c816622ba8f0e6e76879fc00fe2c6153e219 100644 (file)
@@ -210,7 +210,10 @@ static uint64_t dumpNegCache(int fd)
     return 0;
   }
   fprintf(fp.get(), "; negcache dump follows\n;\n");
-  return g_negCache->dumpToFile(fp.get());
+
+  struct timeval now;
+  Utility::gettimeofday(&now, nullptr);
+  return g_negCache->dumpToFile(fp.get(), now);
 }
 
 static uint64_t* pleaseDump(int fd)
index a2e5036867ebc28814d4562a9262e52407d4b38c..72c164b39d746cf460704084dafce3b2b78cef32 100644 (file)
@@ -253,11 +253,9 @@ void NegCache::prune(size_t maxEntries)
  *
  * \param fp A pointer to an open FILE object
  */
-size_t NegCache::dumpToFile(FILE* fp) const
+size_t NegCache::dumpToFile(FILE* fp, const struct timeval& now) const
 {
   size_t ret = 0;
-  struct timeval now;
-  Utility::gettimeofday(&now, nullptr);
 
   for (const auto& m : d_maps) {
     const lock l(m);
index 1618d5af7293ebfc3d1418a579f2899c296b7458..e7bdf3fe83f48d55535ecb96f59a85a56e48d359 100644 (file)
@@ -75,7 +75,7 @@ public:
   size_t count(const DNSName& qname, const QType qtype) const;
   void prune(size_t maxEntries);
   void clear();
-  size_t dumpToFile(FILE* fd) const;
+  size_t dumpToFile(FILE* fd, const struct timeval& now) const;
   size_t wipe(const DNSName& name, bool subtree = false);
   size_t size() const;
 
index 6da6de4749eed75386026e22d1ac306d72d53d07..8c3b38b625382e09d7fcd00cf36a94e46bf6472c 100644 (file)
@@ -437,7 +437,7 @@ BOOST_AUTO_TEST_CASE(test_dumpToFile)
   if (!fp)
     BOOST_FAIL("Temporary file could not be opened");
 
-  cache.dumpToFile(fp.get());
+  cache.dumpToFile(fp.get(), now);
 
   rewind(fp.get());
   char* line = nullptr;
@@ -449,8 +449,7 @@ BOOST_AUTO_TEST_CASE(test_dumpToFile)
     if (read == -1)
       BOOST_FAIL("Unable to read a line from the temp file");
     // The clock might have ticked so the 600 becomes 599
-    auto pos = str.find("600");
-    BOOST_CHECK(line == str || line == str.replace(pos, 3, "599"));
+    BOOST_CHECK(line == str);
   }
 
   /* getline() allocates a buffer when called with a nullptr,