From a512e3d10923f870cbac1b26a2e841086d2d3286 Mon Sep 17 00:00:00 2001 From: phonedph1 Date: Mon, 17 Sep 2018 19:16:56 +0000 Subject: [PATCH] Do some math with the mtasker ttd and print how long a query has been running for --- pdns/pdns_recursor.cc | 2 +- pdns/rec_channel_rec.cc | 8 ++++++-- pdns/syncres.hh | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 65a8baffe7..d9e4f2113f 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -186,7 +186,7 @@ static size_t s_maxUDPQueriesPerRound; static uint64_t g_latencyStatSize; static uint32_t g_disthashseed; static unsigned int g_maxTCPPerClient; -static unsigned int g_networkTimeoutMsec; +unsigned int g_networkTimeoutMsec; static unsigned int g_maxMThreads; static unsigned int g_numDistributorThreads; static unsigned int g_numWorkerThreads; diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc index c19d7ebcc1..9aeb935194 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -692,19 +692,23 @@ static uint64_t calculateUptime() static string* pleaseGetCurrentQueries() { ostringstream ostr; + struct timeval now; + gettimeofday(&now, 0); ostr << getMT()->d_waiters.size() <<" currently outstanding questions\n"; - boost::format fmt("%1% %|40t|%2% %|47t|%3% %|63t|%4% %|68t|%5%\n"); + boost::format fmt("%1% %|40t|%2% %|47t|%3% %|63t|%4% %|68t|%5% %|78t|%6%\n"); - ostr << (fmt % "qname" % "qtype" % "remote" % "tcp" % "chained"); + ostr << (fmt % "qname" % "qtype" % "remote" % "tcp" % "chained" % "spent(ms)"); unsigned int n=0; for(const auto& mthread : getMT()->d_waiters) { const PacketID& pident = mthread.key; + const double spent = g_networkTimeoutMsec - (DiffTime(now, mthread.ttd) * 1000); ostr << (fmt % pident.domain.toLogString() /* ?? */ % DNSRecordContent::NumberToType(pident.type) % pident.remote.toString() % (pident.sock ? 'Y' : 'n') % (pident.fd == -1 ? 'Y' : 'n') + % (spent > 0 ? spent : '0') ); ++n; if (n >= 100) diff --git a/pdns/syncres.hh b/pdns/syncres.hh index 053142f5b1..ea0431cd22 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -981,6 +981,7 @@ string doQueueReloadLuaScript(vector::const_iterator begin, vector::const_iterator begin, vector::const_iterator end); void parseACLs(); extern RecursorStats g_stats; +extern unsigned int g_networkTimeoutMsec; extern unsigned int g_numThreads; extern uint16_t g_outgoingEDNSBufsize; extern std::atomic g_maxCacheEntries, g_maxPacketCacheEntries; -- 2.47.2