From: Miod Vallat Date: Wed, 28 May 2025 12:44:23 +0000 (+0200) Subject: Let AuthZoneCache::removeFromView return whether the view is now empty. X-Git-Tag: dnsdist-2.0.0-beta1~29^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=19c8d37f2f2dbbb0fbe9438017493798f23464cb;p=thirdparty%2Fpdns.git Let AuthZoneCache::removeFromView return whether the view is now empty. --- diff --git a/pdns/auth-zonecache.cc b/pdns/auth-zonecache.cc index 342e269d5f..3833055180 100644 --- a/pdns/auth-zonecache.cc +++ b/pdns/auth-zonecache.cc @@ -277,19 +277,20 @@ void AuthZoneCache::addToView(const std::string& view, const ZoneName& zone) map[view][strictZone] = zone.getVariant(); } -void AuthZoneCache::removeFromView(const std::string& view, const ZoneName& zone) +bool AuthZoneCache::removeFromView(const std::string& view, const ZoneName& zone) { const DNSName& strictZone = zone.operator const DNSName&(); auto views = d_views.write_lock(); AuthZoneCache::ViewsMap& map = *views; if (map.count(view) == 0) { - return; // Nothing to do, we did not know about that view + return true; // Nothing to do, we did not know about that view } auto& innerMap = map.at(view); if (auto iter = innerMap.find(strictZone); iter != innerMap.end()) { innerMap.erase(iter); } // else nothing to do, we did not know about that zone in that view + return innerMap.empty(); } void AuthZoneCache::updateNetwork(const Netmask& network, const std::string& view) diff --git a/pdns/auth-zonecache.hh b/pdns/auth-zonecache.hh index c4459e86c3..ec7babf895 100644 --- a/pdns/auth-zonecache.hh +++ b/pdns/auth-zonecache.hh @@ -46,7 +46,7 @@ public: // Views maintainance void addToView(const std::string& view, const ZoneName& zone); - void removeFromView(const std::string& view, const ZoneName& zone); + bool removeFromView(const std::string& view, const ZoneName& zone); // Network maintainance void updateNetwork(const Netmask& network, const std::string& view);