return *this;
}
-#ifdef RECURSOR
void addTraceTS(const timeval& start, ostringstream& str)
{
const auto& content = str.str();
str << diff << ' ';
}
}
-#endif
using OptLog = std::optional<LogVariant>;
-#ifndef RECURSOR
-// Originally there was a flag but it was never set from !RECURSOR
-#define VLOG(log, x) VLOG only works in recursor
-#else
-
void addTraceTS(const timeval& start, ostringstream& str);
#define VLOG(log, x) \
*std::get<ostringstream*>((log)->v) << x; \
} \
}
-
-#endif
thread_local std::shared_ptr<RecursorLua4> t_pdl;
thread_local std::shared_ptr<Regex> t_traceRegex;
-thread_local int t_tracefd = -1;
+thread_local FDWrapper t_tracefd = -1;
thread_local ProtobufServersInfo t_protobufServers;
thread_local ProtobufServersInfo t_outgoingProtobufServers;
return;
}
std::array<char, 64> timebuf;
- timestamp(timev, timebuf.data(), timebuf.size());
+ isoDateTimeMillis(timev, timebuf.data(), timebuf.size());
fprintf(filep.get(), " us === START OF TRACE %s ===\n", timebuf.data());
fprintf(filep.get(), "%s", trace.c_str());
- timestamp(now, timebuf.data(), timebuf.size());
+ isoDateTimeMillis(now, timebuf.data(), timebuf.size());
fprintf(filep.get(), "=== END OF TRACE %s ===\n", timebuf.data());
// fclose by unique_ptr does implicit flush
}
try {
if (newRegex.empty()) {
t_traceRegex.reset();
- close(t_tracefd);
- t_tracefd = -1;
+ t_tracefd = FDWrapper();
return new string("unset\n");
}
if (file == -1) {
return new string("could not dup file\n");
}
- if (t_tracefd != -1) {
- close(t_tracefd);
- }
t_traceRegex = std::make_shared<Regex>(newRegex);
t_tracefd = file;
return new string("ok\n");
}
- catch (PDNSException& ae) {
+ catch (const PDNSException& ae) {
return new string(ae.reason + "\n");
}
}
extern std::shared_ptr<NetmaskGroup> g_initialAllowNotifyFrom; // new threads need this to be setup
extern std::shared_ptr<notifyset_t> g_initialAllowNotifyFor; // new threads need this to be setup
extern thread_local std::shared_ptr<Regex> t_traceRegex;
-extern thread_local int t_tracefd;
+extern thread_local FDWrapper t_tracefd;
extern string g_programname;
extern string g_pidfname;
extern RecursorControlChannel g_rcc; // only active in the handler thread
return iter != t_sstorage.domainmap->end();
}
-const char* timestamp(const struct timeval& tv, char* buf, size_t sz)
+const char* isoDateTimeMillis(const struct timeval& tv, char* buf, size_t sz)
{
const std::string s_timestampFormat = "%Y-%m-%dT%T";
struct tm tm;
// an <empty> can appear hear in case of authoritative (hosted) zones
char tmp[26];
- fprintf(fp.get(), "%s\t%s\t", i.d_name.toLogString().c_str(), timestamp(i.d_lastget, tmp, sizeof(tmp)));
+ fprintf(fp.get(), "%s\t%s\t", i.d_name.toLogString().c_str(), isoDateTimeMillis(i.d_lastget, tmp, sizeof(tmp)));
bool first = true;
for (const auto& j : i.d_collection) {
fprintf(fp.get(), "%s%s/%.3f/%.3f", first ? "" : "\t", j.first.toStringWithPortExcept(53).c_str(), j.second.peek() / 1000.0f, j.second.last() / 1000.0f);
unsigned int d_timeouts;
unsigned int d_unreachables;
unsigned int d_totUsec;
+ // Initialized ony once, as opposed to d_now which gets updated after outgoing requests
const struct timeval d_fixednow;
private:
std::shared_ptr<std::vector<std::unique_ptr<FrameStreamLogger>>> d_frameStreamServers;
boost::optional<const boost::uuids::uuid&> d_initialRequestId;
asyncresolve_t d_asyncResolve{nullptr};
+ // d_now is initialized in the constructor and updates after outgoing requests in lwres.cc:asyncresolve
struct timeval d_now;
/* if the client is asking for a DS that does not exist, we need to provide the SOA along with the NSEC(3) proof
and we might not have it if we picked up the proof from a delegation */
uint64_t* pleaseGetPacketCacheSize();
void doCarbonDump(void*);
bool primeHints(time_t now = time(nullptr));
-const char* timestamp(const struct timeval& tv, char* buf, size_t sz);
+const char* isoDateTimeMillis(const struct timeval& tv, char* buf, size_t sz);
struct WipeCacheResult
{