From d61b8a0198004347c11e33eb5616bf82fc1f0a5a Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Tue, 24 May 2022 15:47:10 +0200 Subject: [PATCH] Use a name for `const std::shared_ptr&`, call it `Logr::log_t` --- pdns/arguments.hh | 2 +- pdns/pdns_recursor.cc | 8 ++++---- pdns/recursordist/logr.hh | 2 ++ pdns/recursordist/rec-main.cc | 28 ++++++++++++++-------------- pdns/recursordist/rec-main.hh | 10 +++++----- pdns/recursordist/rec-tcp.cc | 2 +- pdns/recursordist/rec-zonetocache.cc | 4 ++-- pdns/reczones.cc | 6 +++--- pdns/rpzloader.cc | 4 ++-- pdns/secpoll-recursor.cc | 2 +- pdns/secpoll-recursor.hh | 2 +- pdns/syncres.cc | 2 +- pdns/syncres.hh | 2 +- pdns/validate-recursor.cc | 2 +- pdns/validate-recursor.hh | 2 +- 15 files changed, 40 insertions(+), 38 deletions(-) diff --git a/pdns/arguments.hh b/pdns/arguments.hh index 1e48ee2b79..29081bfb0c 100644 --- a/pdns/arguments.hh +++ b/pdns/arguments.hh @@ -120,7 +120,7 @@ public: const vector&getCommands(); void gatherIncludes(std::vector &extraConfigs); #ifdef RECURSOR - void setSLog(std::shared_ptr& log) + void setSLog(Logr::log_t log) { d_log = log; } diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 8fd633136b..e888a88da9 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -552,7 +552,7 @@ static PolicyResult handlePolicyHit(const DNSFilterEngine::Policy& appliedPolicy } #ifdef NOD_ENABLED -static bool nodCheckNewDomain(const shared_ptr& nodlogger, const DNSName& dname) +static bool nodCheckNewDomain(Logr::log_t nodlogger, const DNSName& dname) { bool ret = false; // First check the (sub)domain isn't ignored for NOD purposes @@ -570,7 +570,7 @@ static bool nodCheckNewDomain(const shared_ptr& nodlogger, const D return ret; } -static void sendNODLookup(const shared_ptr& nodlogger, const DNSName& dname) +static void sendNODLookup(Logr::log_t nodlogger, const DNSName& dname) { if (!(g_nodLookupDomain.isRoot())) { // Send a DNS A query to .g_nodLookupDomain @@ -591,7 +591,7 @@ static void sendNODLookup(const shared_ptr& nodlogger, const DNSNa } } -static bool udrCheckUniqueDNSRecord(const shared_ptr& nodlogger, const DNSName& dname, uint16_t qtype, const DNSRecord& record) +static bool udrCheckUniqueDNSRecord(Logr::log_t nodlogger, const DNSName& dname, uint16_t qtype, const DNSRecord& record) { bool ret = false; if (record.d_place == DNSResourceRecord::ANSWER || record.d_place == DNSResourceRecord::ADDITIONAL) { @@ -2289,7 +2289,7 @@ static void handleNewUDPQuestion(int fd, FDMultiplexer::funcparam_t& var) } } -void makeUDPServerSockets(deferredAdd_t& deferredAdds, std::shared_ptr& log) +void makeUDPServerSockets(deferredAdd_t& deferredAdds, Logr::log_t log) { int one = 1; vector locals; diff --git a/pdns/recursordist/logr.hh b/pdns/recursordist/logr.hh index 857cc0290b..55959d177f 100644 --- a/pdns/recursordist/logr.hh +++ b/pdns/recursordist/logr.hh @@ -175,4 +175,6 @@ private: return; } }; + +using log_t = const std::shared_ptr&; } diff --git a/pdns/recursordist/rec-main.cc b/pdns/recursordist/rec-main.cc index fbc5eacd67..e1b43a860d 100644 --- a/pdns/recursordist/rec-main.cc +++ b/pdns/recursordist/rec-main.cc @@ -111,7 +111,7 @@ unsigned int RecThreadInfo::s_numDistributorThreads; unsigned int RecThreadInfo::s_numWorkerThreads; thread_local unsigned int RecThreadInfo::t_id; -static std::map> parseCPUMap(std::shared_ptr& log) +static std::map> parseCPUMap(Logr::log_t log) { std::map> result; @@ -156,7 +156,7 @@ static std::map> parseCPUMap(std::shared_ptr>& cpusMap, unsigned int n, pthread_t tid, std::shared_ptr& log) +static void setCPUMap(const std::map>& cpusMap, unsigned int n, pthread_t tid, Logr::log_t log) { const auto& cpuMapping = cpusMap.find(n); if (cpuMapping == cpusMap.cend()) { @@ -191,7 +191,7 @@ static void setCPUMap(const std::map>& cpusMap, unsi static void recursorThread(); -void RecThreadInfo::start(unsigned int id, const string& tname, const std::map>& cpusMap, std::shared_ptr& log) +void RecThreadInfo::start(unsigned int id, const string& tname, const std::map>& cpusMap, Logr::log_t log) { name = tname; thread = std::thread([id, tname] { @@ -203,7 +203,7 @@ void RecThreadInfo::start(unsigned int id, const string& tname, const std::map& log) +int RecThreadInfo::runThreads(Logr::log_t log) { int ret = EXIT_SUCCESS; unsigned int currentThreadId = 1; @@ -291,7 +291,7 @@ int RecThreadInfo::runThreads(std::shared_ptr& log) return ret; } -void RecThreadInfo::makeThreadPipes(std::shared_ptr& log) +void RecThreadInfo::makeThreadPipes(Logr::log_t log) { auto pipeBufferSize = ::arg().asNum("distribution-pipe-buffer-size"); if (pipeBufferSize > 0) { @@ -352,7 +352,7 @@ ArgvMap& arg() return theArg; } -static FDMultiplexer* getMultiplexer(std::shared_ptr& log) +static FDMultiplexer* getMultiplexer(Logr::log_t log) { FDMultiplexer* ret; for (const auto& i : FDMultiplexer::getMultiplexerMap()) { @@ -670,7 +670,7 @@ static void makeControlChannelSocket(int processNum = -1) } } -static void writePid(std::shared_ptr& log) +static void writePid(Logr::log_t log) { if (!::arg().mustDo("write-pid")) return; @@ -684,7 +684,7 @@ static void writePid(std::shared_ptr& log) } } -static void checkSocketDir(std::shared_ptr& log) +static void checkSocketDir(Logr::log_t log) { struct stat st; string dir(::arg()["socket-dir"]); @@ -708,7 +708,7 @@ static void checkSocketDir(std::shared_ptr& log) } #ifdef NOD_ENABLED -static void setupNODThread(std::shared_ptr& log) +static void setupNODThread(Logr::log_t log) { if (g_nodEnabled) { uint32_t num_cells = ::arg().asNum("new-domain-db-size"); @@ -776,7 +776,7 @@ static void setupNODGlobal() } #endif /* NOD_ENABLED */ -static void daemonize(std::shared_ptr& log) +static void daemonize(Logr::log_t log) { if (fork()) exit(0); // bye bye @@ -814,7 +814,7 @@ static void usr2Handler(int) ::arg().set("quiet") = g_quiet ? "" : "no"; } -static void checkLinuxIPv6Limits(std::shared_ptr& log) +static void checkLinuxIPv6Limits(Logr::log_t log) { #ifdef __linux__ string line; @@ -828,7 +828,7 @@ static void checkLinuxIPv6Limits(std::shared_ptr& log) #endif } -static void checkOrFixFDS(std::shared_ptr& log) +static void checkOrFixFDS(Logr::log_t log) { unsigned int availFDs = getFilenumLimit(); unsigned int wantFDs = g_maxMThreads * RecThreadInfo::numWorkers() + 25; // even healthier margin then before @@ -964,7 +964,7 @@ static void doStats(void) statsWanted = false; } -static std::shared_ptr parseACL(const std::string& aclFile, const std::string& aclSetting, std::shared_ptr& log) +static std::shared_ptr parseACL(const std::string& aclFile, const std::string& aclSetting, Logr::log_t log) { auto result = std::make_shared(); @@ -1212,7 +1212,7 @@ template vector broadcastAccFunction(const std::function> broadcastAccFunction(const std::function>*()>& fun); // explicit instantiation template ThreadTimes broadcastAccFunction(const std::function& fun); -static int serviceMain(int argc, char* argv[], std::shared_ptr& log) +static int serviceMain(int argc, char* argv[], Logr::log_t log) { g_log.setName(g_programname); g_log.disableSyslog(::arg().mustDo("disable-syslog")); diff --git a/pdns/recursordist/rec-main.hh b/pdns/recursordist/rec-main.hh index 7fe9a1568d..94a9a903f3 100644 --- a/pdns/recursordist/rec-main.hh +++ b/pdns/recursordist/rec-main.hh @@ -446,8 +446,8 @@ public: return numHandlers() + numDistributors() + numWorkers() + numTaskThreads(); } - static int runThreads(std::shared_ptr&); - static void makeThreadPipes(std::shared_ptr&); + static int runThreads(Logr::log_t); + static void makeThreadPipes(Logr::log_t); void setExitCode(int e) { @@ -468,7 +468,7 @@ public: uint64_t numberOfDistributedQueries{0}; private: - void start(unsigned int id, const string& name, const std::map>& cpusMap, std::shared_ptr&); + void start(unsigned int id, const string& name, const std::map>& cpusMap, Logr::log_t); std::string name; std::thread thread; @@ -525,10 +525,10 @@ bool expectProxyProtocol(const ComboAddress& from); void finishTCPReply(std::unique_ptr& dc, bool hadError, bool updateInFlight); void checkFastOpenSysctl(bool active); void checkTFOconnect(); -void makeTCPServerSockets(deferredAdd_t& deferredAdds, std::set& tcpSockets, std::shared_ptr&); +void makeTCPServerSockets(deferredAdd_t& deferredAdds, std::set& tcpSockets, Logr::log_t); void handleNewTCPQuestion(int fd, FDMultiplexer::funcparam_t&); -void makeUDPServerSockets(deferredAdd_t& deferredAdds, std::shared_ptr&); +void makeUDPServerSockets(deferredAdd_t& deferredAdds, Logr::log_t); #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 599350af59..52d5c0c909 100644 --- a/pdns/recursordist/rec-tcp.cc +++ b/pdns/recursordist/rec-tcp.cc @@ -994,7 +994,7 @@ LWResult::Result arecvtcp(PacketBuffer& data, const size_t len, shared_ptr& tcpSockets, std::shared_ptr& log) +void makeTCPServerSockets(deferredAdd_t& deferredAdds, std::set& tcpSockets, Logr::log_t log) { int fd; vector locals; diff --git a/pdns/recursordist/rec-zonetocache.cc b/pdns/recursordist/rec-zonetocache.cc index 3918766ac5..ace8686464 100644 --- a/pdns/recursordist/rec-zonetocache.cc +++ b/pdns/recursordist/rec-zonetocache.cc @@ -40,7 +40,7 @@ struct ZoneData { - ZoneData(shared_ptr& log, const std::string& zone) : + ZoneData(Logr::log_t log, const std::string& zone) : d_log(log), d_zone(zone), d_now(time(nullptr)) {} @@ -53,7 +53,7 @@ struct ZoneData // Maybe use a SuffixMatchTree? std::set d_delegations; - shared_ptr& d_log; + Logr::log_t d_log; DNSName d_zone; time_t d_now; diff --git a/pdns/reczones.cc b/pdns/reczones.cc index 24ca8cf486..67a2805aa3 100644 --- a/pdns/reczones.cc +++ b/pdns/reczones.cc @@ -197,7 +197,7 @@ void primeRootNSZones(DNSSECMode mode, unsigned int depth) } } -static void makeNameToIPZone(std::shared_ptr newMap, const DNSName& hostname, const string& ip, std::shared_ptr& log) +static void makeNameToIPZone(std::shared_ptr newMap, const DNSName& hostname, const string& ip, Logr::log_t log) { SyncRes::AuthDomain ad; ad.d_rdForward = false; @@ -234,7 +234,7 @@ static void makeNameToIPZone(std::shared_ptr newMap, const } //! parts[0] must be an IP address, the rest must be host names -static void makeIPToNamesZone(std::shared_ptr newMap, const vector& parts, std::shared_ptr& log) +static void makeIPToNamesZone(std::shared_ptr newMap, const vector& parts, Logr::log_t log) { string address = parts[0]; vector ipparts; @@ -283,7 +283,7 @@ static void makeIPToNamesZone(std::shared_ptr newMap, cons } } -static void convertServersForAD(const std::string& zone, const std::string& input, SyncRes::AuthDomain& ad, const char* sepa, std::shared_ptr& log, bool verbose = true) +static void convertServersForAD(const std::string& zone, const std::string& input, SyncRes::AuthDomain& ad, const char* sepa, Logr::log_t log, bool verbose = true) { vector servers; stringtok(servers, input, sepa); diff --git a/pdns/rpzloader.cc b/pdns/rpzloader.cc index d8350bdebe..b047182c6b 100644 --- a/pdns/rpzloader.cc +++ b/pdns/rpzloader.cc @@ -188,7 +188,7 @@ static void RPZRecordToPolicy(const DNSRecord& dr, std::shared_ptr loadRPZFromServer(const shared_ptr& plogger, const ComboAddress& primary, const DNSName& zoneName, std::shared_ptr zone, const boost::optional& defpol, bool defpolOverrideLocal, uint32_t maxTTL, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, uint16_t axfrTimeout) +static shared_ptr loadRPZFromServer(Logr::log_t plogger, const ComboAddress& primary, const DNSName& zoneName, std::shared_ptr zone, const boost::optional& defpol, bool defpolOverrideLocal, uint32_t maxTTL, const TSIGTriplet& tt, size_t maxReceivedBytes, const ComboAddress& localAddress, uint16_t axfrTimeout) { auto logger = plogger->withValues("primary", Logging::Loggable(primary)); @@ -319,7 +319,7 @@ std::shared_ptr loadRPZFromFile(const std::string& fname, std: return sr; } -static bool dumpZoneToDisk(const shared_ptr& plogger, const DNSName& zoneName, const std::shared_ptr& newZone, const std::string& dumpZoneFileName) +static bool dumpZoneToDisk(Logr::log_t plogger, const DNSName& zoneName, const std::shared_ptr& newZone, const std::string& dumpZoneFileName) { auto logger = plogger->v(1); logger->info("Dumping zone to disk", "destination_file", Logging::Loggable(dumpZoneFileName)); diff --git a/pdns/secpoll-recursor.cc b/pdns/secpoll-recursor.cc index be3d105d70..91774af85c 100644 --- a/pdns/secpoll-recursor.cc +++ b/pdns/secpoll-recursor.cc @@ -17,7 +17,7 @@ uint32_t g_security_status; string g_security_message; -void doSecPoll(time_t* last_secpoll, std::shared_ptr& log) +void doSecPoll(time_t* last_secpoll, Logr::log_t log) { if (::arg()["security-poll-suffix"].empty()) return; diff --git a/pdns/secpoll-recursor.hh b/pdns/secpoll-recursor.hh index cfa77fa320..8fc6f4074d 100644 --- a/pdns/secpoll-recursor.hh +++ b/pdns/secpoll-recursor.hh @@ -25,6 +25,6 @@ #include "logr.hh" #include -void doSecPoll(time_t*, std::shared_ptr&); +void doSecPoll(time_t*, Logr::log_t); extern uint32_t g_security_status; extern std::string g_security_message; diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 1c6ee2aa0f..6a0c26b182 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -5670,7 +5670,7 @@ int directResolve(const DNSName& qname, const QType qtype, const QClass qclass, return res; } -int SyncRes::getRootNS(struct timeval now, asyncresolve_t asyncCallback, unsigned int depth, std::shared_ptr& log) { +int SyncRes::getRootNS(struct timeval now, asyncresolve_t asyncCallback, unsigned int depth, Logr::log_t log) { SyncRes sr(now); sr.setDoEDNS0(true); sr.setUpdatingRootNS(); diff --git a/pdns/syncres.hh b/pdns/syncres.hh index a47365db72..4ec3e51906 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -184,7 +184,7 @@ public: static uint64_t doDumpSavedParentNSSets(int fd); static uint64_t doDumpDoTProbeMap(int fd); - static int getRootNS(struct timeval now, asyncresolve_t asyncCallback, unsigned int depth, std::shared_ptr&); + static int getRootNS(struct timeval now, asyncresolve_t asyncCallback, unsigned int depth, Logr::log_t); static void addDontQuery(const std::string& mask) { if (!s_dontQuery) diff --git a/pdns/validate-recursor.cc b/pdns/validate-recursor.cc index 545b815ff0..a8b0ae8755 100644 --- a/pdns/validate-recursor.cc +++ b/pdns/validate-recursor.cc @@ -41,7 +41,7 @@ vState increaseXDNSSECStateCounter(const vState& state) } // Returns true if dsAnchors were modified -bool updateTrustAnchorsFromFile(const std::string& fname, map& dsAnchors, std::shared_ptr& log) +bool updateTrustAnchorsFromFile(const std::string& fname, map& dsAnchors, Logr::log_t log) { map newDSAnchors; try { diff --git a/pdns/validate-recursor.hh b/pdns/validate-recursor.hh index a45304a477..7062162832 100644 --- a/pdns/validate-recursor.hh +++ b/pdns/validate-recursor.hh @@ -46,4 +46,4 @@ bool checkDNSSECDisabled(); bool warnIfDNSSECDisabled(const string& msg); vState increaseDNSSECStateCounter(const vState& state); vState increaseXDNSSECStateCounter(const vState& state); -bool updateTrustAnchorsFromFile(const std::string& fname, map& dsAnchors, std::shared_ptr&); +bool updateTrustAnchorsFromFile(const std::string& fname, map& dsAnchors, Logr::log_t); -- 2.47.2