From: Otto Moerbeek Date: Mon, 31 Jan 2022 09:23:18 +0000 (+0100) Subject: Use scoping to make a clear distinction between thread-specific statics and general... X-Git-Tag: auth-4.7.0-alpha1~19^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4991c19eb1286a6fad82fb63094c43cf5e548fa;p=thirdparty%2Fpdns.git Use scoping to make a clear distinction between thread-specific statics and general thread_local ones. --- diff --git a/pdns/recursordist/rec-main.cc b/pdns/recursordist/rec-main.cc index aaad2df72e..fda1340d72 100644 --- a/pdns/recursordist/rec-main.cc +++ b/pdns/recursordist/rec-main.cc @@ -1796,26 +1796,23 @@ static void handleRCC(int fd, FDMultiplexer::funcparam_t& var) static void houseKeeping(void*) { - static thread_local time_t t_last_rootupdate, t_last_secpoll, t_last_trustAnchorUpdate{0}; - static thread_local struct timeval t_last_prune; - - static thread_local int t_cleanCounter = 0; - static thread_local bool t_running; // houseKeeping can get suspended in secpoll, and be restarted, which makes us do duplicate work - static time_t s_last_RC_prune = 0; - static time_t s_last_ZTC_prune = 0; + static thread_local time_t t_last_trustAnchorUpdate{0}; // all threads + static thread_local struct timeval t_last_prune{0, 0}; // all threads + static thread_local int t_cleanCounter{0}; // all threads + static thread_local bool t_running{false}; // houseKeeping can get suspended in secpoll, and be restarted, which makes us do duplicate work auto luaconfsLocal = g_luaconfs.getLocal(); - if (t_last_trustAnchorUpdate == 0 && !luaconfsLocal->trustAnchorFileInfo.fname.empty() && luaconfsLocal->trustAnchorFileInfo.interval != 0) { - // Loading the Lua config file already "refreshed" the TAs - t_last_trustAnchorUpdate = g_now.tv_sec + luaconfsLocal->trustAnchorFileInfo.interval * 3600; - } - try { if (t_running) { return; } t_running = true; + if (t_last_trustAnchorUpdate == 0 && !luaconfsLocal->trustAnchorFileInfo.fname.empty() && luaconfsLocal->trustAnchorFileInfo.interval != 0) { + // Loading the Lua config file already "refreshed" the TAs + t_last_trustAnchorUpdate = g_now.tv_sec + luaconfsLocal->trustAnchorFileInfo.interval * 3600; + } + struct timeval now, past; Utility::gettimeofday(&now, nullptr); past = now; @@ -1838,6 +1835,7 @@ static void houseKeeping(void*) const auto& info = RecThreadInfo::self(); if (RecThreadInfo::self().isTaskThread()) { + static time_t s_last_ZTC_prune{0}; runTaskOnce(g_logCommonErrors); if (now.tv_sec - s_last_ZTC_prune > 60) { s_last_ZTC_prune = now.tv_sec; @@ -1850,6 +1848,8 @@ static void houseKeeping(void*) } if (info.isHandler()) { + static time_t t_last_rootupdate{0}, t_last_secpoll{0}; + static time_t s_last_RC_prune{0}; if (now.tv_sec - s_last_RC_prune > 5) { g_recCache->doPrune(g_maxCacheEntries); g_negCache->prune(g_maxCacheEntries / 10);