From: Remi Gacogne Date: Tue, 7 Aug 2018 10:02:21 +0000 (+0200) Subject: rec: Copy the cached protobuf message instead of creating a new one X-Git-Tag: dnsdist-1.3.3~6^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=294780113e3f72ac0c5f0165008274a9a3e2b38d;p=thirdparty%2Fpdns.git rec: Copy the cached protobuf message instead of creating a new one (cherry picked from commit 80b94844f488b5acfc41a4aaf33640d63d076b11) --- diff --git a/pdns/protobuf.cc b/pdns/protobuf.cc index a726e2c599..37fb01e8b1 100644 --- a/pdns/protobuf.cc +++ b/pdns/protobuf.cc @@ -337,4 +337,9 @@ DNSProtoBufMessage::DNSProtoBufMessage(DNSProtoBufMessageType type, const boost: setQuestion(domain, qtype, qclass); } +void DNSProtoBufMessage::copyFrom(const DNSProtoBufMessage& msg) +{ + d_message.CopyFrom(msg.d_message); +} + #endif /* HAVE_PROTOBUF */ diff --git a/pdns/protobuf.hh b/pdns/protobuf.hh index 42491bc87f..fc070acb98 100644 --- a/pdns/protobuf.hh +++ b/pdns/protobuf.hh @@ -80,6 +80,7 @@ public: void update(const boost::uuids::uuid& uuid, const ComboAddress* requestor, const ComboAddress* responder, bool isTCP, uint16_t id); void setUUID(const boost::uuids::uuid& uuid); void setInitialRequestID(const boost::uuids::uuid& uuid); + void copyFrom(const DNSProtoBufMessage& msg); protected: PBDNSMessage d_message; diff --git a/pdns/recpacketcache.cc b/pdns/recpacketcache.cc index 6faf00ae64..102b022510 100644 --- a/pdns/recpacketcache.cc +++ b/pdns/recpacketcache.cc @@ -77,7 +77,7 @@ bool RecursorPacketCache::checkResponseMatches(std::paird_protobufMessage) { - *protobufMessage = *(iter->d_protobufMessage); + protobufMessage->copyFrom(*(iter->d_protobufMessage)); } else { *protobufMessage = RecProtoBufMessage(DNSProtoBufMessage::DNSProtoBufMessageType::Response);