From: Otto Moerbeek Date: Mon, 31 Jan 2022 08:24:13 +0000 (+0100) Subject: Use correct bound for getting CPU stats. There's an inconsistentcy here: X-Git-Tag: auth-4.7.0-alpha1~19^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a0a3a61a3e55d62ae3c9cb208c0780ee114c9162;p=thirdparty%2Fpdns.git Use correct bound for getting CPU stats. There's an inconsistentcy here: broadcastAccFunction does not include the handler, but does include the taskThread This has to be made consistent. For the moment, keep the existing behaviour. --- diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc index 9678bbeaec..9523d738b9 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -1118,7 +1118,9 @@ static StatsMap toCPUStatsMap(const string& name) { const string pbasename = getPrometheusName(name); StatsMap entries; - for (unsigned int n = 0; n < RecThreadInfo::numRecursorThreads(); ++n) { + // Only distr and worker threads, I think we should revisit this as we now not only have the handler thread but also + // taskThread(s). + for (unsigned int n = 0; n < RecThreadInfo::numDistributors() + RecThreadInfo::numWorkers(); ++n) { uint64_t tm = doGetThreadCPUMsec(n); std::string pname = pbasename + "{thread=\"" + std::to_string(n) + "\"}"; entries.emplace(name + "-thread-" + std::to_string(n), StatsMapEntry{pname, std::to_string(tm)}); diff --git a/pdns/recursordist/rec-main.cc b/pdns/recursordist/rec-main.cc index 4a98bbc0de..aaad2df72e 100644 --- a/pdns/recursordist/rec-main.cc +++ b/pdns/recursordist/rec-main.cc @@ -174,6 +174,8 @@ static void setCPUMap(const std::map>& cpusMap, unsi } } +static void recursorThread(); + void RecThreadInfo::start(unsigned int id, const string& name, const std::map>& cpusMap) { thread = std::thread([id, name] { @@ -1096,10 +1098,11 @@ static vector>& operator+=(vector T broadcastAccFunction(const boost::function& func) { @@ -1934,7 +1937,7 @@ static void houseKeeping(void*) } } -void* recursorThread() +static void recursorThread() { try { auto& threadInfo = RecThreadInfo::self(); @@ -1952,7 +1955,6 @@ void* recursorThread() threadInfo.setExitCode(EXIT_FAILURE); RecursorControlChannel::stop = 1; g_log << Logger::Critical << "Priming cache failed, stopping" << endl; - return nullptr; } g_log << Logger::Debug << "Done priming cache with root hints" << endl; } @@ -2139,19 +2141,15 @@ void* recursorThread() } } } - return nullptr; } catch (PDNSException& ae) { g_log << Logger::Error << "Exception: " << ae.reason << endl; - return nullptr; } catch (std::exception& e) { g_log << Logger::Error << "STL Exception: " << e.what() << endl; - return nullptr; } catch (...) { g_log << Logger::Error << "any other exception in main: " << endl; - return nullptr; } } diff --git a/pdns/recursordist/rec-main.hh b/pdns/recursordist/rec-main.hh index 650df429b5..d21c63e583 100644 --- a/pdns/recursordist/rec-main.hh +++ b/pdns/recursordist/rec-main.hh @@ -290,8 +290,6 @@ static bool sendResponseOverTCP(const std::unique_ptr& dc, const return hadError; } -void* recursorThread(); - // For communicating with our threads effectively readonly after // startup. // First we have the handler thread, t_id == 0 (some other helper