*
* \param fp A pointer to an open FILE object
*/
-size_t NegCache::doDump(int fd, size_t maxCacheEntries)
+size_t NegCache::doDump(int fd, size_t maxCacheEntries, time_t now)
{
int newfd = dup(fd);
if (newfd == -1) {
}
fprintf(fp.get(), "; negcache dump follows\n;\n");
- struct timeval now;
- Utility::gettimeofday(&now, nullptr);
-
size_t ret = 0;
size_t shard = 0;
auto& sidx = m->d_map.get<SequenceTag>();
for (const NegCacheEntry& ne : sidx) {
ret++;
- int64_t ttl = ne.d_ttd - now.tv_sec;
+ int64_t ttl = ne.d_ttd - now;
fprintf(fp.get(), "%s %" PRId64 " IN %s VIA %s ; (%s) origttl=%" PRIu32 " ss=%hu\n", ne.d_name.toString().c_str(), ttl, ne.d_qtype.toString().c_str(), ne.d_auth.toString().c_str(), vStateToString(ne.d_validationState).c_str(), ne.d_orig_ttl, ne.d_servedStale);
for (const auto& rec : ne.authoritySOA.records) {
fprintf(fp.get(), "%s %" PRId64 " IN %s %s ; (%s)\n", rec.d_name.toString().c_str(), ttl, DNSRecordContent::NumberToType(rec.d_type).c_str(), rec.getContent()->getZoneRepresentation().c_str(), vStateToString(ne.d_validationState).c_str());
size_t count(const DNSName& qname, QType qtype);
void prune(size_t maxEntries);
void clear();
- size_t doDump(int fd, size_t maxCacheEntries);
+ size_t doDump(int fd, size_t maxCacheEntries, time_t now = time(nullptr));
size_t wipe(const DNSName& name, bool subtree = false);
size_t wipeTyped(const DNSName& name, QType qtype);
size_t size() const;
if (!fp)
BOOST_FAIL("Temporary file could not be opened");
- cache.doDump(fileno(fp.get()), 0);
+ cache.doDump(fileno(fp.get()), 0, now.tv_sec);
rewind(fp.get());
char* line = nullptr;