From: Remi Gacogne Date: Mon, 29 Oct 2018 10:15:09 +0000 (+0100) Subject: rec: Use unique instead of shared pointers for the RemoteLoggers X-Git-Tag: auth-4.2.0-alpha1~50^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F7088%2Fhead;p=thirdparty%2Fpdns.git rec: Use unique instead of shared pointers for the RemoteLoggers --- diff --git a/pdns/lwres.cc b/pdns/lwres.cc index 540823abdf..d4765b0b7b 100644 --- a/pdns/lwres.cc +++ b/pdns/lwres.cc @@ -50,7 +50,7 @@ #ifdef HAVE_PROTOBUF -static void logOutgoingQuery(const std::shared_ptr>>& outgoingLoggers, boost::optional initialRequestId, const boost::uuids::uuid& uuid, const ComboAddress& ip, const DNSName& domain, int type, uint16_t qid, bool doTCP, size_t bytes, boost::optional& srcmask) +static void logOutgoingQuery(const std::shared_ptr>>& outgoingLoggers, boost::optional initialRequestId, const boost::uuids::uuid& uuid, const ComboAddress& ip, const DNSName& domain, int type, uint16_t qid, bool doTCP, size_t bytes, boost::optional& srcmask) { if(!outgoingLoggers) return; @@ -75,7 +75,7 @@ static void logOutgoingQuery(const std::shared_ptr>>& outgoingLoggers, boost::optional initialRequestId, const boost::uuids::uuid& uuid, const ComboAddress& ip, const DNSName& domain, int type, uint16_t qid, bool doTCP, size_t bytes, int rcode, const std::vector& records, const struct timeval& queryTime, const std::set& exportTypes) +static void logIncomingResponse(const std::shared_ptr>>& outgoingLoggers, boost::optional initialRequestId, const boost::uuids::uuid& uuid, const ComboAddress& ip, const DNSName& domain, int type, uint16_t qid, bool doTCP, size_t bytes, int rcode, const std::vector& records, const struct timeval& queryTime, const std::set& exportTypes) { if(!outgoingLoggers) return; @@ -103,7 +103,7 @@ static void logIncomingResponse(const std::shared_ptr& srcmask, boost::optional context, const std::shared_ptr>>& outgoingLoggers, const std::set& exportTypes, LWResult *lwr, bool* chained) +int asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, struct timeval* now, boost::optional& srcmask, boost::optional context, const std::shared_ptr>>& outgoingLoggers, const std::set& exportTypes, LWResult *lwr, bool* chained) { size_t len; size_t bufsize=g_outgoingEDNSBufsize; diff --git a/pdns/lwres.hh b/pdns/lwres.hh index a548206bf9..5ddc3af0da 100644 --- a/pdns/lwres.hh +++ b/pdns/lwres.hh @@ -68,5 +68,5 @@ public: bool d_haveEDNS{false}; }; -int asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, struct timeval* now, boost::optional& srcmask, boost::optional context, const std::shared_ptr>>& outgoingLoggers, const std::set& exportTypes, LWResult* res, bool* chained); +int asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, struct timeval* now, boost::optional& srcmask, boost::optional context, const std::shared_ptr>>& outgoingLoggers, const std::set& exportTypes, LWResult* res, bool* chained); #endif // PDNS_LWRES_HH diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 17f7051b6b..97aa582926 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -109,9 +109,9 @@ static thread_local unsigned int t_id = 0; static thread_local std::shared_ptr t_traceRegex; static thread_local std::unique_ptr t_tcpClientCounts; #ifdef HAVE_PROTOBUF -static thread_local std::shared_ptr>> t_protobufServers{nullptr}; +static thread_local std::shared_ptr>> t_protobufServers{nullptr}; static thread_local uint64_t t_protobufServersGeneration; -static thread_local std::shared_ptr>> t_outgoingProtobufServers{nullptr}; +static thread_local std::shared_ptr>> t_outgoingProtobufServers{nullptr}; static thread_local uint64_t t_outgoingProtobufServersGeneration; #endif /* HAVE_PROTOBUF */ @@ -866,13 +866,13 @@ static bool addRecordToPacket(DNSPacketWriter& pw, const DNSRecord& rec, uint32_ } #ifdef HAVE_PROTOBUF -static std::shared_ptr>> startProtobufServers(const ProtobufExportConfig& config) +static std::shared_ptr>> startProtobufServers(const ProtobufExportConfig& config) { - auto result = std::make_shared>>(); + auto result = std::make_shared>>(); for (const auto& server : config.servers) { try { - result->push_back(std::make_shared(server, config.timeout, config.maxQueuedEntries, config.reconnectWaitTime, config.asyncConnect)); + result->emplace_back(new RemoteLogger(server, config.timeout, config.maxQueuedEntries, config.reconnectWaitTime, config.asyncConnect)); } catch(const std::exception& e) { g_log<& srcmask, boost::optional context, const std::shared_ptr>>& outgoingLoggers, const std::set& exportTypes, LWResult* res, bool* chained) +int asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, struct timeval* now, boost::optional& srcmask, boost::optional context, const std::shared_ptr>>& outgoingLoggers, const std::set& exportTypes, LWResult* res, bool* chained) { return 0; } diff --git a/pdns/syncres.hh b/pdns/syncres.hh index 32fbdb9ea8..cb2a448591 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -659,7 +659,7 @@ public: d_initialRequestId = initialRequestId; } - void setOutgoingProtobufServers(std::shared_ptr>>& servers) + void setOutgoingProtobufServers(std::shared_ptr>>& servers) { d_outgoingProtobufServers = servers; } @@ -804,7 +804,7 @@ private: ostringstream d_trace; shared_ptr d_pdl; boost::optional d_outgoingECSNetwork; - std::shared_ptr>> d_outgoingProtobufServers{nullptr}; + std::shared_ptr>> d_outgoingProtobufServers{nullptr}; #ifdef HAVE_PROTOBUF boost::optional d_initialRequestId; #endif