]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Review comments by @chbruyand, remove some redundant code for the catz case
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 5 Nov 2024 08:50:23 +0000 (09:50 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 5 Nov 2024 08:50:23 +0000 (09:50 +0100)
pdns/recursordist/rec-main.cc
pdns/recursordist/rec-xfr.cc
pdns/recursordist/rec-xfr.hh

index 3e9b60b081064b99efd70db9ef17275337e80905..39a1d2c6971927153ba58cfdf667a57a2818c64e 100644 (file)
@@ -3556,10 +3556,7 @@ static void activateForwardingCatalogZones(LuaConfigItems& lci)
     auto& params = fcz.d_params;
     params.zoneIdx = idx++;
     auto zone = std::make_shared<CatalogZone>();
-    if (params.zoneSizeHint != 0) {
-      zone->reserve(params.zoneSizeHint);
-    }
-
+    // zoneSizeHint ignored
     DNSName domain(params.name);
     zone->setName(domain);
     fcz.d_catz = zone;
index 3eb3e8dc65527a037a77a28fa759fe7e340d0af2..3fa26e0c890a27c30eefcfc8e67918ed7758e50f 100644 (file)
@@ -190,8 +190,8 @@ static shared_ptr<const SOARecordContent> loadZoneFromServer(Logr::log_t plogger
   Resolver::res_t nop;
   vector<DNSRecord> chunk;
   time_t last = 0;
-  time_t axfrStart = time(nullptr);
-  time_t axfrNow = time(nullptr);
+  const time_t axfrStart = time(nullptr);
+  time_t axfrNow = axfrStart;
   shared_ptr<const SOARecordContent> soaRecordContent;
   // coverity[store_truncates_time_t]
   while (axfr.getChunk(nop, &chunk, (axfrStart + axfrTimeout - axfrNow)) != 0) {
@@ -244,7 +244,7 @@ void FWCatZoneXFR::preloadZoneFile(const DNSName& zoneName, std::shared_ptr<Cata
         newZone->setSerial(d_params.soaRecordContent->d_st.serial);
         newZone->setRefresh(d_params.soaRecordContent->d_st.refresh);
         refresh = std::max(d_params.refreshFromConf != 0 ? d_params.refreshFromConf : newZone->getRefresh(), 1U);
-        newZone->newStats(d_params.soaRecordContent->d_st.serial, true);
+        // XXX Stats
 
         g_luaconfs.modify([zoneIdx = d_params.zoneIdx, &newZone](LuaConfigItems& lci) {
           lci.catalogzones.at(zoneIdx).d_catz = newZone;
@@ -257,11 +257,11 @@ void FWCatZoneXFR::preloadZoneFile(const DNSName& zoneName, std::shared_ptr<Cata
       }
       catch (const std::exception& e) {
         logger->error(Logr::Warning, e.what(), "Unable to load zone, will retry", "from", Logging::Loggable(primary), "exception", Logging::Loggable("std::exception"), "refresh", Logging::Loggable(refresh));
-        oldZone->incFailedStats();
+        // XXX Stats
       }
       catch (const PDNSException& e) {
         logger->error(Logr::Warning, e.reason, "Unable to load zone, will retry", "from", Logging::Loggable(primary), "exception", Logging::Loggable("PDNSException"), "refresh", Logging::Loggable(refresh));
-        oldZone->incFailedStats();
+        // XXX Stats
       }
     }
     // Release newZone before (long) sleep to reduce memory usage
@@ -339,7 +339,7 @@ bool FWCatZoneXFR::zoneTrackerIteration(const DNSName& zoneName, std::shared_ptr
     catch (const std::runtime_error& e) {
       logger->error(Logr::Warning, e.what(), "Exception during retrieval of delta", "exception", Logging::Loggable("std::runtime_error"));
       if (oldZone) {
-        oldZone->incFailedStats();
+        // XXX Stats
       }
       continue;
     }
@@ -366,9 +366,8 @@ bool FWCatZoneXFR::zoneTrackerIteration(const DNSName& zoneName, std::shared_ptr
     /* initialize the current serial to the last one */
     std::shared_ptr<const SOARecordContent> currentSR = d_params.soaRecordContent;
 
-    int totremove = 0;
-    int totadd = 0;
-    bool fullUpdate = false;
+    int removed = 0;
+    int added = 0;
 
     for (const auto& delta : deltas) {
       const auto& remove = delta.first;
@@ -376,7 +375,6 @@ bool FWCatZoneXFR::zoneTrackerIteration(const DNSName& zoneName, std::shared_ptr
       if (remove.empty()) {
         logger->info(Logr::Warning, "IXFR update is a whole new zone");
         newZone->clear();
-        fullUpdate = true;
       }
       for (const auto& resourceRecord : remove) { // should always contain the SOA
         if (resourceRecord.d_type == QType::NS) {
@@ -395,7 +393,7 @@ bool FWCatZoneXFR::zoneTrackerIteration(const DNSName& zoneName, std::shared_ptr
           }
         }
         else {
-          totremove++;
+          removed++;
           logger->info(Logr::Debug, "Remove from zone", "name", Logging::Loggable(resourceRecord.d_name));
           newZone->remove(resourceRecord, logger);
         }
@@ -412,7 +410,7 @@ bool FWCatZoneXFR::zoneTrackerIteration(const DNSName& zoneName, std::shared_ptr
           }
         }
         else {
-          totadd++;
+          added++;
           logger->info(Logr::Debug, "Addition to zone", "name", Logging::Loggable(resourceRecord.d_name));
           newZone->add(resourceRecord, logger);
         }
@@ -429,10 +427,10 @@ bool FWCatZoneXFR::zoneTrackerIteration(const DNSName& zoneName, std::shared_ptr
     if (currentSR) {
       d_params.soaRecordContent = std::move(currentSR);
     }
-    logger->info(Logr::Info, "Zone mutations", "removals", Logging::Loggable(totremove), "additions", Logging::Loggable(totadd), "newserial", Logging::Loggable(d_params.soaRecordContent->d_st.serial));
+    logger->info(Logr::Info, "Zone mutations", "removals", Logging::Loggable(removed), "additions", Logging::Loggable(added), "newserial", Logging::Loggable(d_params.soaRecordContent->d_st.serial));
     newZone->setSerial(d_params.soaRecordContent->d_st.serial);
     newZone->setRefresh(d_params.soaRecordContent->d_st.refresh);
-    newZone->newStats(d_params.soaRecordContent->d_st.serial, fullUpdate);
+    // XXX Stats
 
     /* we need to replace the existing zone with the new one,
        but we don't want to touch anything else, especially other zones,
index 0dd49ebcb818566a14b0183e58437acb2fb05c03..cd5f8db67b8c48da84545da0806bfbb6e0c4ac7c 100644 (file)
@@ -76,22 +76,10 @@ public:
   {
     return d_name;
   }
-  void reserve([[maybe_unused]] size_t size)
-  {
-    // d_records.reserve(size);
-  }
   void clear()
   {
     d_records.clear();
   }
-  void newStats([[maybe_unused]] uint32_t serial, [[maybe_unused]] bool fullTransfer)
-  {
-    // XXX stats
-  }
-  void incFailedStats()
-  {
-    // XXX stats
-  }
   void add(const DNSRecord& record, Logr::log_t logger);
   void remove(const DNSRecord& record, Logr::log_t logger);
   void registerForwarders(const FWCatz& params, Logr::log_t logger);