From: Otto Moerbeek Date: Mon, 4 Nov 2024 08:47:36 +0000 (+0100) Subject: Refactor doGenericTopRemotes() X-Git-Tag: rec-5.2.0-alpha1~2^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71b7c5162fc4509ba530a15623e1d3f158090416;p=thirdparty%2Fpdns.git Refactor doGenericTopRemotes() --- diff --git a/pdns/recursordist/rec_channel_rec.cc b/pdns/recursordist/rec_channel_rec.cc index 9fc6230740..21e9e0a676 100644 --- a/pdns/recursordist/rec_channel_rec.cc +++ b/pdns/recursordist/rec_channel_rec.cc @@ -1516,20 +1516,20 @@ vector* pleaseGetTimeouts() static string doGenericTopRemotes(const pleaseremotefunc_t& func) { std::map counts; - auto remotes = broadcastAccFunction>(func); - - unsigned int total = 0; + if (remotes.empty()) { + return "No data available\n"; + } + const unsigned int total = remotes.size(); for (const auto& address : remotes) { - total++; counts[address]++; } std::multimap rcounts; - for (auto& count : counts) { rcounts.emplace(-count.second, count.first); } + ostringstream ret; ret << "Over last " << total << " entries:\n"; boost::format fmt("%.02f%%\t%s\n");