From 397ed71dedda21effaaad2578b27fd316c00451d Mon Sep 17 00:00:00 2001 From: Leon Xu Date: Thu, 11 Jan 2018 18:00:32 +0800 Subject: [PATCH] speed up IXFR transcation IXFR client actively close connection to server once IXFR is done --- pdns/ixfr.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pdns/ixfr.cc b/pdns/ixfr.cc index 54bb8781ad..ab0fc6210a 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,8 +207,8 @@ vector, vector > > getIXFRDeltas(const ComboAd throw std::runtime_error("The first record of the IXFR answer for zone '"+zone.toLogString()+"' from master '"+master.toStringWithPort()+"' is not a SOA ("+QType(r.first.d_type).getName()+")"); } - auto sr = getRR(r.first); - if (!sr) { + 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()+"'"); } @@ -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) { -- 2.47.2