From 4b0bdd5fdb881c94de8daf59c1da6f13e1a39d79 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Tue, 7 Aug 2018 14:23:43 +0200 Subject: [PATCH] rec: Move the protobuf message as well when inserting the cache (cherry picked from commit 3853eaa72aeb8a14ebfd303a229b738c2d891b5a) --- pdns/pdns_recursor.cc | 2 +- pdns/recpacketcache.cc | 8 ++++---- pdns/recpacketcache.hh | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 373b7650b6..7c344c9325 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1517,7 +1517,7 @@ static void startDoResolve(void *p) dq.validationState, dc->d_ecsBegin, dc->d_ecsEnd, - pbMessage); + std::move(pbMessage)); } // else cerr<<"Not putting in packet cache: "< pb(boost::none); - insertResponsePacket(tag, qhash, std::move(query), qname, qtype, qclass, std::move(responsePacket), now, ttl, valState, ecsBegin, ecsEnd, pb); + insertResponsePacket(tag, qhash, std::move(query), qname, qtype, qclass, std::move(responsePacket), now, ttl, valState, ecsBegin, ecsEnd, std::move(pb)); } -void RecursorPacketCache::insertResponsePacket(unsigned int tag, uint32_t qhash, std::string&& query, const DNSName& qname, uint16_t qtype, uint16_t qclass, std::string&& responsePacket, time_t now, uint32_t ttl, const vState& valState, uint16_t ecsBegin, uint16_t ecsEnd, const boost::optional& protobufMessage) +void RecursorPacketCache::insertResponsePacket(unsigned int tag, uint32_t qhash, std::string&& query, const DNSName& qname, uint16_t qtype, uint16_t qclass, std::string&& responsePacket, time_t now, uint32_t ttl, const vState& valState, uint16_t ecsBegin, uint16_t ecsEnd, boost::optional&& protobufMessage) { auto& idx = d_packetCache.get(); auto range = idx.equal_range(tie(tag,qhash)); @@ -178,7 +178,7 @@ void RecursorPacketCache::insertResponsePacket(unsigned int tag, uint32_t qhash, iter->d_vstate = valState; #ifdef HAVE_PROTOBUF if (protobufMessage) { - iter->d_protobufMessage = *protobufMessage; + iter->d_protobufMessage = std::move(*protobufMessage); } #endif @@ -198,7 +198,7 @@ void RecursorPacketCache::insertResponsePacket(unsigned int tag, uint32_t qhash, e.d_vstate = valState; #ifdef HAVE_PROTOBUF if (protobufMessage) { - e.d_protobufMessage = *protobufMessage; + e.d_protobufMessage = std::move(*protobufMessage); } #endif d_packetCache.insert(e); diff --git a/pdns/recpacketcache.hh b/pdns/recpacketcache.hh index 435c5edf74..36a76c650a 100644 --- a/pdns/recpacketcache.hh +++ b/pdns/recpacketcache.hh @@ -57,7 +57,7 @@ public: bool getResponsePacket(unsigned int tag, const std::string& queryPacket, const DNSName& qname, uint16_t qtype, uint16_t qclass, time_t now, std::string* responsePacket, uint32_t* age, vState* valState, uint32_t* qhash, uint16_t* ecsBegin, uint16_t* ecsEnd, RecProtoBufMessage* protobufMessage); bool getResponsePacket(unsigned int tag, const std::string& queryPacket, DNSName& qname, uint16_t* qtype, uint16_t* qclass, time_t now, std::string* responsePacket, uint32_t* age, vState* valState, uint32_t* qhash, uint16_t* ecsBegin, uint16_t* ecsEnd, RecProtoBufMessage* protobufMessage); void insertResponsePacket(unsigned int tag, uint32_t qhash, std::string&& query, const DNSName& qname, uint16_t qtype, uint16_t qclass, std::string&& responsePacket, time_t now, uint32_t ttl, uint16_t ecsBegin, uint16_t ecsEnd); - void insertResponsePacket(unsigned int tag, uint32_t qhash, std::string&& query, const DNSName& qname, uint16_t qtype, uint16_t qclass, std::string&& responsePacket, time_t now, uint32_t ttl, const vState& valState, uint16_t ecsBegin, uint16_t ecsEnd, const boost::optional& protobufMessage); + void insertResponsePacket(unsigned int tag, uint32_t qhash, std::string&& query, const DNSName& qname, uint16_t qtype, uint16_t qclass, std::string&& responsePacket, time_t now, uint32_t ttl, const vState& valState, uint16_t ecsBegin, uint16_t ecsEnd, boost::optional&& protobufMessage); void doPruneTo(unsigned int maxSize=250000); uint64_t doDump(int fd); int doWipePacketCache(const DNSName& name, uint16_t qtype=0xffff, bool subtree=false); -- 2.47.2