Utility::gettimeofday(&now);
// Below are the tasks that run for every recursorThread, including handler and taskThread
- static thread_local PeriodicTask packetCacheTask{"packetCacheTask", 5};
- packetCacheTask.runIfDue(now, []() {
- t_packetCache->doPruneTo(g_maxPacketCacheEntries / (RecThreadInfo::numDistributors() + RecThreadInfo::numWorkers()));
- });
+ if (t_packetCache) {
+ static thread_local PeriodicTask packetCacheTask{"packetCacheTask", 5};
+ packetCacheTask.runIfDue(now, []() {
+ size_t sz = g_maxPacketCacheEntries / (RecThreadInfo::numWorkers() + RecThreadInfo::numDistributors());
+ t_packetCache->setMaxSize(sz); // g_maxPacketCacheEntries might have changed by rec_control
+ t_packetCache->doPruneTo(sz);
+ });
+ }
- // This is a full scan
- static thread_local PeriodicTask pruneNSpeedTask{"pruneNSSpeedTask", 100};
- pruneNSpeedTask.runIfDue(now, [now]() {
- SyncRes::pruneNSSpeeds(now.tv_sec - 300);
- });
-
static thread_local PeriodicTask pruneEDNSTask{"pruneEDNSTask", 5}; // period could likely be longer
pruneEDNSTask.runIfDue(now, [now]() {
SyncRes::pruneEDNSStatuses(now.tv_sec - 2 * 3600);