converting ttd to ttl as an arg in the negCache dump.
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)
*
* \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);
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;
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;
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,