From: Peter van Dijk Date: Sun, 11 Sep 2022 11:31:02 +0000 (+0200) Subject: auth LUA records: we only need one IsUpOracle checker thread X-Git-Tag: rec-4.8.0-alpha1~19^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=37f625b0af0b5e818de97b83dd96709df118ad6b;p=thirdparty%2Fpdns.git auth LUA records: we only need one IsUpOracle checker thread --- diff --git a/pdns/lua-record.cc b/pdns/lua-record.cc index 16ad0b9e70..c13373b79f 100644 --- a/pdns/lua-record.cc +++ b/pdns/lua-record.cc @@ -76,7 +76,7 @@ private: }; public: - IsUpOracle() + IsUpOracle(): d_checkerThreadStarted(ATOMIC_FLAG_INIT) { } ~IsUpOracle() @@ -203,6 +203,7 @@ private: SharedLockGuarded d_statuses; std::unique_ptr d_checkerThread; + std::atomic_flag d_checkerThreadStarted; void setStatus(const CheckDesc& cd, bool status) { @@ -240,7 +241,7 @@ private: bool IsUpOracle::isUp(const CheckDesc& cd) { - if (!d_checkerThread) { + if (!d_checkerThreadStarted.test_and_set()) { d_checkerThread = std::make_unique([this] { return checkThread(); }); } time_t now = time(nullptr);