]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: Move the protobuf message as well when inserting the cache
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 7 Aug 2018 12:23:43 +0000 (14:23 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 2 Nov 2018 15:56:03 +0000 (16:56 +0100)
(cherry picked from commit 3853eaa72aeb8a14ebfd303a229b738c2d891b5a)

pdns/pdns_recursor.cc
pdns/recpacketcache.cc
pdns/recpacketcache.hh

index 373b7650b6f547b598ea2d564e83358d536e691d..7c344c93255255357bc4716a0af991d333a23e2f 100644 (file)
@@ -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: "<<sr.wasVariable()<<endl;
     }
index 102b022510fade3e5e1ee656ad90245a841256b4..29262159e6990626974b4bc5930d72a050c47d39 100644 (file)
@@ -154,10 +154,10 @@ void RecursorPacketCache::insertResponsePacket(unsigned int tag, uint32_t qhash,
 {
   vState valState;
   boost::optional<RecProtoBufMessage> 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<RecProtoBufMessage>& 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<RecProtoBufMessage>&& protobufMessage)
 {
   auto& idx = d_packetCache.get<HashTag>();
   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);
index 435c5edf7469bf25ad3fac5d6bddba6672b36620..36a76c650a1183320a382e2241099a498479a818 100644 (file)
@@ -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<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, const vState& valState, uint16_t ecsBegin, uint16_t ecsEnd, boost::optional<RecProtoBufMessage>&& protobufMessage);
   void doPruneTo(unsigned int maxSize=250000);
   uint64_t doDump(int fd);
   int doWipePacketCache(const DNSName& name, uint16_t qtype=0xffff, bool subtree=false);