]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Small refactor: split out forwarding cat zone code from xfr code
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 8 Oct 2024 07:49:48 +0000 (09:49 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 4 Nov 2024 14:20:14 +0000 (15:20 +0100)
In an ideal world we should share the xfr code between RPZ and catz, but
that is for a later day.

pdns/recursordist/rec-main.cc
pdns/recursordist/rec-xfr.cc
pdns/recursordist/rec-xfr.hh

index 974414a3a9545654b2b32d6f72b960d9267c0eef..3e9b60b081064b99efd70db9ef17275337e80905 100644 (file)
@@ -3432,7 +3432,7 @@ void startLuaConfigDelayedThreads(const LuaConfigItems& luaConfig, uint64_t gene
     try {
       // ZoneXFRTracker uses call by value for its args. That is essential, since we want copies so
       // that ZoneXFRTracker gets values with the proper lifetime.
-      std::thread theThread(ZoneXFR::zoneXFRTracker, fcz.d_params, generation);
+      std::thread theThread(FWCatZoneXFR::zoneXFRTracker, fcz.d_params, generation);
       theThread.detach();
     }
     catch (const std::exception& e) {
index 265617cb4f273714ec6f178905cb9515b35b88c7..1273d5a7347a927d7f6b3248ef0d5f52a7adff2f 100644 (file)
@@ -231,7 +231,7 @@ static shared_ptr<const SOARecordContent> loadZoneFromServer(Logr::log_t plogger
   return soaRecordContent;
 }
 
-void ZoneXFR::preloadZoneFile(const DNSName& zoneName, std::shared_ptr<CatalogZone>& oldZone, uint32_t& refresh, uint64_t configGeneration, ZoneWaiter& waiter, Logr::log_t logger)
+void FWCatZoneXFR::preloadZoneFile(const DNSName& zoneName, std::shared_ptr<CatalogZone>& oldZone, uint32_t& refresh, uint64_t configGeneration, ZoneWaiter& waiter, Logr::log_t logger)
 {
   while (!d_params.soaRecordContent) {
     /* if we received an empty sr, the zone was not really preloaded */
@@ -283,7 +283,7 @@ void ZoneXFR::preloadZoneFile(const DNSName& zoneName, std::shared_ptr<CatalogZo
   }
 }
 
-bool ZoneXFR::zoneTrackerIteration(const DNSName& zoneName, std::shared_ptr<CatalogZone>& oldZone, uint32_t& refresh, bool& skipRefreshDelay, uint64_t configGeneration, ZoneWaiter& waiter, Logr::log_t logger)
+bool FWCatZoneXFR::zoneTrackerIteration(const DNSName& zoneName, std::shared_ptr<CatalogZone>& oldZone, uint32_t& refresh, bool& skipRefreshDelay, uint64_t configGeneration, ZoneWaiter& waiter, Logr::log_t logger)
 {
   // Don't hold on to oldZone, it well be re-assigned after sleep in the try block
   oldZone = nullptr;
@@ -458,7 +458,7 @@ bool ZoneXFR::zoneTrackerIteration(const DNSName& zoneName, std::shared_ptr<Cata
 }
 
 // coverity[pass_by_value] params is intended to be a copy, as this is the main function of a thread
-void ZoneXFR::zoneXFRTracker(ZoneXFRParams params, uint64_t configGeneration) // NOLINT(performance-unnecessary-value-param)
+void FWCatZoneXFR::zoneXFRTracker(ZoneXFRParams params, uint64_t configGeneration) // NOLINT(performance-unnecessary-value-param)
 {
   setThreadName("rec/fwcatzixfr");
   bool isPreloaded = params.soaRecordContent != nullptr;
@@ -484,7 +484,7 @@ void ZoneXFR::zoneXFRTracker(ZoneXFRParams params, uint64_t configGeneration) //
 
   insertZoneTracker(zoneName, waiter);
 
-  ZoneXFR xfrObject(params);
+  FWCatZoneXFR xfrObject(params);
   xfrObject.preloadZoneFile(zoneName, oldZone, refresh, configGeneration, waiter, logger);
   bool skipRefreshDelay = isPreloaded;
   while (xfrObject.zoneTrackerIteration(zoneName, oldZone, refresh, skipRefreshDelay, configGeneration, waiter, logger)) {
index 5923527e4f83f8dc105da9969fc74a76fb20e33a..85fc125916e26e3a8e016691438ea39bb40c34de 100644 (file)
@@ -130,15 +130,11 @@ public:
   static bool notifyZoneTracker(const DNSName& name);
   static void insertZoneTracker(const DNSName& zoneName, ZoneWaiter& waiter);
   static void clearZoneTracker(const DNSName& zoneName);
-  static void zoneXFRTracker(ZoneXFRParams params, uint64_t configGeneration);
 
   ZoneXFR(ZoneXFRParams params) :
     d_params(std::move(params))
   {}
 
-private:
-  void preloadZoneFile(const DNSName& zoneName, std::shared_ptr<CatalogZone>& oldZone, uint32_t& refresh, uint64_t configGeneration, ZoneWaiter& waiter, Logr::log_t logger);
-  bool zoneTrackerIteration(const DNSName& zoneName, std::shared_ptr<CatalogZone>& oldZone, uint32_t& refresh, bool& skipRefreshDelay, uint64_t configGeneration, ZoneWaiter& waiter, Logr::log_t logger);
 
   ZoneXFRParams d_params;
 
@@ -147,4 +143,17 @@ private:
   static LockGuarded<std::multimap<DNSName, ZoneXFR::ZoneWaiter&>> condVars;
 };
 
+class FWCatZoneXFR : ZoneXFR
+{
+public:
+  FWCatZoneXFR(ZoneXFRParams params) :
+    ZoneXFR(std::move(params))
+  {}
+
+  static void zoneXFRTracker(ZoneXFRParams params, uint64_t configGeneration);
+private:
+  void preloadZoneFile(const DNSName& zoneName, std::shared_ptr<CatalogZone>& oldZone, uint32_t& refresh, uint64_t configGeneration, ZoneWaiter& waiter, Logr::log_t logger);
+  bool zoneTrackerIteration(const DNSName& zoneName, std::shared_ptr<CatalogZone>& oldZone, uint32_t& refresh, bool& skipRefreshDelay, uint64_t configGeneration, ZoneWaiter& waiter, Logr::log_t logger);
+};
+
 std::string reloadZoneConfiguration(bool yaml);