From: Remi Gacogne Date: Fri, 4 Jun 2021 15:04:41 +0000 (+0200) Subject: Move ixfrdist to LockGuarded X-Git-Tag: dnsdist-1.7.0-alpha1~11^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ffb1b049ec6ab721add414e1aeb77eeb29c9167a;p=thirdparty%2Fpdns.git Move ixfrdist to LockGuarded --- diff --git a/pdns/ixfrdist.cc b/pdns/ixfrdist.cc index f7d58eb30f..aea08ee066 100644 --- a/pdns/ixfrdist.cc +++ b/pdns/ixfrdist.cc @@ -42,6 +42,7 @@ #include "mplexer.hh" #include "misc.hh" #include "iputils.hh" +#include "lock.hh" #include "logger.hh" #include "ixfrdist-stats.hh" #include "ixfrdist-web.hh" @@ -147,8 +148,7 @@ struct ixfrdistdomain_t { static map g_domainConfigs; // Map domains and their data -static std::map> g_soas; -static std::mutex g_soas_mutex; +static LockGuarded>> g_soas; // Condition variable for TCP handling static std::condition_variable g_tcpHandlerCV; @@ -218,7 +218,7 @@ static void cleanUpDomain(const DNSName& domain, const uint16_t& keep, const str // And delete all the old ones { // Lock to ensure no one reads this. - std::lock_guard guard(g_soas_mutex); + auto lock = g_soas.lock(); for (auto iter = zoneVersions.cbegin(); iter != zoneVersions.cend() - keep; ++iter) { string fname = dir + "/" + std::to_string(*iter); g_log< getCurrentZoneInfo(const DNSName& domain) { - std::lock_guard guard(g_soas_mutex); - return g_soas[domain]; + return (*g_soas.lock())[domain]; } static void updateCurrentZoneInfo(const DNSName& domain, std::shared_ptr& newInfo) { - std::lock_guard guard(g_soas_mutex); - g_soas[domain] = newInfo; + auto soas = g_soas.lock(); + (*soas)[domain] = newInfo; g_stats.setSOASerial(domain, newInfo->soa->d_st.serial); // FIXME: also report zone size? }