From: Otto Moerbeek Date: Wed, 27 Mar 2024 10:08:46 +0000 (+0100) Subject: Explain the d_cachedir_mutex is only used for protecting init() calls X-Git-Tag: rec-5.1.0-alpha1~77^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F13969%2Fhead;p=thirdparty%2Fpdns.git Explain the d_cachedir_mutex is only used for protecting init() calls --- diff --git a/pdns/recursordist/nod.hh b/pdns/recursordist/nod.hh index fb59c35100..1cc8f456dc 100644 --- a/pdns/recursordist/nod.hh +++ b/pdns/recursordist/nod.hh @@ -69,7 +69,10 @@ private: LockGuarded d_sbf; // Stable Bloom Filter std::string d_cachedir; std::string d_prefix = sbf_prefix; - static std::mutex d_cachedir_mutex; // One mutex for all instances of this class + // One mutex for all instances of this class, used to avoid multiple init() calls happening + // simulateneously. The snapshot code is thread safe wrt file operations, so it does not need to + // acquire this mutex, assuming the init() code never runs simulatenously with the snapshot code. + static std::mutex d_cachedir_mutex; }; class NODDB