]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
speed up IXFR transcation
authorLeon Xu <cassvin91@gmail.com>
Thu, 11 Jan 2018 10:00:32 +0000 (18:00 +0800)
committerLeon Xu <cassvin91@gmail.com>
Thu, 11 Jan 2018 10:00:32 +0000 (18:00 +0800)
IXFR client actively close connection to server once IXFR is done

pdns/ixfr.cc

index 54bb8781adedc0bfe8f76980b160e18096d85428..ab0fc6210a943bb0a9b0f5d3cd2433a32674aefb 100644 (file)
@@ -168,8 +168,12 @@ vector<pair<vector<DNSRecord>, vector<DNSRecord> > > getIXFRDeltas(const ComboAd
   std::shared_ptr<SOARecordContent> masterSOA = nullptr;
   vector<DNSRecord> 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<pair<vector<DNSRecord>, vector<DNSRecord> > > 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<SOARecordContent>(r.first);
-       if (!sr) {
+        auto sr = getRR<SOARecordContent>(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<pair<vector<DNSRecord>, vector<DNSRecord> > > 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<SOARecordContent>(r.first)->d_st.serial) {
+          ixfrInProgress++;
+        }
       }
 
       if(r.first.d_place != DNSResourceRecord::ANSWER) {