From: Otto Moerbeek Date: Fri, 24 Nov 2023 10:34:15 +0000 (+0100) Subject: Rename authWaitTime() to make it explicit we're talking milliseconds X-Git-Tag: rec-5.1.0-beta1~22^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c6f67d8194008199d8c67bda4e2e7b3e68e991d3;p=thirdparty%2Fpdns.git Rename authWaitTime() to make it explicit we're talking milliseconds --- diff --git a/pdns/recursordist/pdns_recursor.cc b/pdns/recursordist/pdns_recursor.cc index 921d429a31..da94b29fa9 100644 --- a/pdns/recursordist/pdns_recursor.cc +++ b/pdns/recursordist/pdns_recursor.cc @@ -251,7 +251,7 @@ PacketBuffer GenUDPQueryResponse(const ComboAddress& dest, const string& query) t_fdm->addReadFD(socket.getHandle(), handleGenUDPQueryResponse, pident); PacketBuffer data; - int ret = g_multiTasker->waitEvent(pident, &data, authWaitTime(g_multiTasker)); + int ret = g_multiTasker->waitEvent(pident, &data, authWaitTimeMSec(g_multiTasker)); if (ret == 0 || ret == -1) { // timeout t_fdm->removeReadFD(socket.getHandle()); @@ -269,7 +269,7 @@ thread_local std::unique_ptr t_udpclientsocks; // If we have plenty of mthreads slot left, use default timeout. // Othwerwise reduce the timeout to be between g_networkTimeoutMsec/10 and g_networkTimeoutMsec -unsigned int authWaitTime(const std::unique_ptr& mtasker) +unsigned int authWaitTimeMSec(const std::unique_ptr& mtasker) { const auto max = g_maxMThreads; const auto current = mtasker->numProcesses(); @@ -308,12 +308,12 @@ LWResult::Result asendto(const void* data, size_t len, int /* flags */, *fileDesc = -1; // gets used in waitEvent / sendEvent later on auto currentChainSize = chain.first->key->authReqChain.size(); if (g_maxChainLength > 0 && currentChainSize >= g_maxChainLength) { - return LWResult::Result::OSLimitError; + return LWResult::Result::OSLimitError; } - assert(uSec(chain.first->key->creationTime) != 0); + assert(uSec(chain.first->key->creationTime) != 0); // NOLINT auto age = now - chain.first->key->creationTime; - if (uSec(age) > static_cast(1000) * authWaitTime(g_multiTasker) * 2 / 3) { - return LWResult::Result::OSLimitError; + if (uSec(age) > static_cast(1000) * authWaitTimeMSec(g_multiTasker) * 2 / 3) { + return LWResult::Result::OSLimitError; } chain.first->key->authReqChain.insert(qid); // we can chain auto maxLength = t_Counters.at(rec::Counter::maxChainLength); @@ -360,7 +360,7 @@ LWResult::Result arecvfrom(PacketBuffer& packet, int /* flags */, const ComboAdd pident->remote = fromAddr; pident->creationTime = now; - int ret = g_multiTasker->waitEvent(pident, &packet, authWaitTime(g_multiTasker), &now); + int ret = g_multiTasker->waitEvent(pident, &packet, authWaitTimeMSec(g_multiTasker), &now); len = 0; /* -1 means error, 0 means timeout, 1 means a result from handleUDPServerResponse() which might still be an error */ @@ -513,7 +513,7 @@ public: } private: - std::unique_ptr& d_dc; + std::unique_ptr& d_dc; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members) bool d_handled{false}; }; diff --git a/pdns/recursordist/rec-main.hh b/pdns/recursordist/rec-main.hh index 7bec94eb39..c69e4de74a 100644 --- a/pdns/recursordist/rec-main.hh +++ b/pdns/recursordist/rec-main.hh @@ -624,7 +624,7 @@ string doTraceRegex(FDWrapper file, vector::const_iterator begin, vector extern bool g_luaSettingsInYAML; void startLuaConfigDelayedThreads(const vector& rpzs, uint64_t generation); void activateLuaConfig(LuaConfigItems& lci); -unsigned int authWaitTime(const std::unique_ptr& mtasker); +unsigned int authWaitTimeMSec(const std::unique_ptr& mtasker); #define LOCAL_NETS "127.0.0.0/8, 10.0.0.0/8, 100.64.0.0/10, 169.254.0.0/16, 192.168.0.0/16, 172.16.0.0/12, ::1/128, fc00::/7, fe80::/10" #define LOCAL_NETS_INVERSE "!127.0.0.0/8, !10.0.0.0/8, !100.64.0.0/10, !169.254.0.0/16, !192.168.0.0/16, !172.16.0.0/12, !::1/128, !fc00::/7, !fe80::/10" diff --git a/pdns/recursordist/rec-tcp.cc b/pdns/recursordist/rec-tcp.cc index d391df5322..4d1a055fff 100644 --- a/pdns/recursordist/rec-tcp.cc +++ b/pdns/recursordist/rec-tcp.cc @@ -1060,7 +1060,7 @@ LWResult::Result arecvtcp(PacketBuffer& data, const size_t len, shared_ptrlowState TCPIOHandlerStateChange(IOState::Done, state, pident); - int ret = g_multiTasker->waitEvent(pident, &data, authWaitTime(g_multiTasker)); + int ret = g_multiTasker->waitEvent(pident, &data, authWaitTimeMSec(g_multiTasker)); TCPLOG(pident->tcpsock, "arecvtcp " << ret << ' ' << data.size() << ' '); if (ret == 0) { TCPLOG(pident->tcpsock, "timeout" << endl);