From: Remi Gacogne Date: Mon, 4 Jul 2016 09:45:18 +0000 (+0200) Subject: rec: Don't call `commit()` if we skipped all the records X-Git-Tag: rec-4.0.0~2^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F4096%2Fhead;p=thirdparty%2Fpdns.git rec: Don't call `commit()` if we skipped all the records --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 33c9364a85..fd12a64d34 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1012,7 +1012,8 @@ void startDoResolve(void *p) if(haveEDNS) { ret.push_back(makeOpt(edo.d_packetsize, 0, edo.d_Z)); } - + + bool needCommit = false; for(auto i=ret.cbegin(); i!=ret.cend(); ++i) { if(!DNSSECOK && (i->d_type == QType::RRSIG || i->d_type==QType::NSEC || i->d_type==QType::NSEC3)) continue; @@ -1029,6 +1030,7 @@ void startDoResolve(void *p) } goto sendit; // need to jump over pw.commit } + needCommit = true; #ifdef HAVE_PROTOBUF if(luaconfsLocal->protobufServer && protobufResponse && (i->d_type == QType::A || i->d_type == QType::AAAA)) { PBDNSMessage_DNSResponse_DNSRR* pbRR = protobufResponse->add_rrs(); @@ -1051,7 +1053,7 @@ void startDoResolve(void *p) } #endif } - if(ret.size()) + if(needCommit) pw.commit(); } sendit:;