From: Leon Xu Date: Thu, 11 Jan 2018 10:00:32 +0000 (+0800) Subject: speed up IXFR transcation X-Git-Tag: rec-4.1.2~1^2^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9d663e67b5af9f39b0d12795dae005be15c6175b;p=thirdparty%2Fpdns.git speed up IXFR transcation IXFR client actively close connection to server once IXFR is done (cherry picked from commit 397ed71dedda21effaaad2578b27fd316c00451d) --- diff --git a/pdns/ixfr.cc b/pdns/ixfr.cc index 74982b518f..152b512fd9 100644 --- a/pdns/ixfr.cc +++ b/pdns/ixfr.cc @@ -168,8 +168,12 @@ vector, vector > > getIXFRDeltas(const ComboAd std::shared_ptr masterSOA = nullptr; vector records; size_t receivedBytes = 0; + int8_t ixfrInProgress = -2; for(;;) { + if (!ixfrInProgress) + break; + if(s.read((char*)&len, sizeof(len)) != sizeof(len)) break; @@ -203,9 +207,9 @@ vector, vector > > getIXFRDeltas(const ComboAd throw std::runtime_error("The first record of the IXFR answer for zone '"+zone.toString()+"' from master '"+master.toStringWithPort()+"' is not a SOA ("+QType(r.first.d_type).getName()+")"); } - auto sr = getRR(r.first); - if (!sr) { - throw std::runtime_error("Error getting the content of the first SOA record of the IXFR answer for zone '"+zone.toString()+"' from master '"+master.toStringWithPort()+"'"); + auto sr = getRR(r.first); + if (!sr) { + throw std::runtime_error("Error getting the content of the first SOA record of the IXFR answer for zone '"+zone.toLogString()+"' from master '"+master.toStringWithPort()+"'"); } if(sr->d_st.serial == std::dynamic_pointer_cast(oursr.d_content)->d_st.serial) { @@ -213,6 +217,12 @@ vector, vector > > getIXFRDeltas(const ComboAd return ret; } masterSOA = sr; + } else { + // we hit the last SOA record + // ixfr is considered to be done if we hit the last SOA record twice + if (r.first.d_type == QType::SOA && masterSOA->d_st.serial == getRR(r.first)->d_st.serial) { + ixfrInProgress++; + } } if(r.first.d_place != DNSResourceRecord::ANSWER) {