From: Otto Moerbeek Date: Tue, 5 Nov 2024 08:50:23 +0000 (+0100) Subject: Review comments by @chbruyand, remove some redundant code for the catz case X-Git-Tag: rec-5.2.0-alpha1~7^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f70ab77efe5d622ceb7cdbf1426eb6c6bd27dc0;p=thirdparty%2Fpdns.git Review comments by @chbruyand, remove some redundant code for the catz case --- diff --git a/pdns/recursordist/rec-main.cc b/pdns/recursordist/rec-main.cc index 3e9b60b081..39a1d2c697 100644 --- a/pdns/recursordist/rec-main.cc +++ b/pdns/recursordist/rec-main.cc @@ -3556,10 +3556,7 @@ static void activateForwardingCatalogZones(LuaConfigItems& lci) auto& params = fcz.d_params; params.zoneIdx = idx++; auto zone = std::make_shared(); - if (params.zoneSizeHint != 0) { - zone->reserve(params.zoneSizeHint); - } - + // zoneSizeHint ignored DNSName domain(params.name); zone->setName(domain); fcz.d_catz = zone; diff --git a/pdns/recursordist/rec-xfr.cc b/pdns/recursordist/rec-xfr.cc index 3eb3e8dc65..3fa26e0c89 100644 --- a/pdns/recursordist/rec-xfr.cc +++ b/pdns/recursordist/rec-xfr.cc @@ -190,8 +190,8 @@ static shared_ptr loadZoneFromServer(Logr::log_t plogger Resolver::res_t nop; vector 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 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_ptrsetSerial(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_ptrerror(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 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, diff --git a/pdns/recursordist/rec-xfr.hh b/pdns/recursordist/rec-xfr.hh index 0dd49ebcb8..cd5f8db67b 100644 --- a/pdns/recursordist/rec-xfr.hh +++ b/pdns/recursordist/rec-xfr.hh @@ -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);