From: Peter van Dijk Date: Wed, 26 Apr 2023 17:05:21 +0000 (+0200) Subject: refactor getCatalogMembers X-Git-Tag: auth-4.8.0-beta1~1^2~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bdf49371abd31b5aa80271cd5b4a838cc17b177d;p=thirdparty%2Fpdns.git refactor getCatalogMembers --- diff --git a/modules/lmdbbackend/lmdbbackend.cc b/modules/lmdbbackend/lmdbbackend.cc index 4b127bb6cb..749b4acb2b 100644 --- a/modules/lmdbbackend/lmdbbackend.cc +++ b/modules/lmdbbackend/lmdbbackend.cc @@ -1759,26 +1759,29 @@ void LMDBBackend::setNotified(uint32_t domain_id, uint32_t serial) bool LMDBBackend::getCatalogMembers(const DNSName& catalog, vector& members, CatalogInfo::CatalogType type) { - auto txn = d_tdomains->getROTransaction(); - for (auto iter = txn.begin(); iter != txn.end(); ++iter) { - if ((type == CatalogInfo::CatalogType::Producer && iter->kind != DomainInfo::Master) || (type == CatalogInfo::CatalogType::Consumer && iter->kind != DomainInfo::Slave) || iter->catalog != catalog) { - continue; + vector scratch; + + getAllDomainsFiltered(&scratch, [this, &catalog, &members, &type](DomainInfo& di) { + if ((type == CatalogInfo::CatalogType::Producer && di.kind != DomainInfo::Master) || (type == CatalogInfo::CatalogType::Consumer && di.kind != DomainInfo::Slave) || di.catalog != catalog) { + return false; } CatalogInfo ci; - ci.d_id = iter->id; - ci.d_zone = iter->zone; - ci.d_primaries = iter->masters; + ci.d_id = di.id; + ci.d_zone = di.zone; + ci.d_primaries = di.masters; try { - ci.fromJson(iter->options, type); + ci.fromJson(di.options, type); } catch (const std::runtime_error& e) { - g_log << Logger::Warning << __PRETTY_FUNCTION__ << " options '" << iter->options << "' for zone '" << iter->zone << "' is no valid JSON: " << e.what() << endl; + g_log << Logger::Warning << __PRETTY_FUNCTION__ << " options '" << di.options << "' for zone '" << di.zone << "' is no valid JSON: " << e.what() << endl; members.clear(); return false; } members.emplace_back(ci); - } + + return false; + }); return true; }