}
t_running = true;
- runTaskOnce(g_logCommonErrors);
-
struct timeval now, past;
Utility::gettimeofday(&now, nullptr);
past = now;
Utility::gettimeofday(&t_last_prune, nullptr);
}
- if (RecThreadInfo::self().isHandler()) {
+ const auto& info = RecThreadInfo::self();
+
+ if (RecThreadInfo::self().isTaskThread()) {
+ runTaskOnce(g_logCommonErrors);
if (now.tv_sec - s_last_ZTC_prune > 60) {
s_last_ZTC_prune = now.tv_sec;
static map<DNSName, RecZoneToCache::State> ztcStates;
RecZoneToCache::ZoneToCache(ztc.second, ztcStates.at(ztc.first));
}
}
+ }
+
+ if (info.isHandler()) {
if (now.tv_sec - s_last_RC_prune > 5) {
g_recCache->doPrune(g_maxCacheEntries);
g_negCache->prune(g_maxCacheEntries / 10);
// Use primes, it avoid not being scheduled in cases where the counter has a regular pattern.
// We want to call handler thread often, it gets scheduled about 2 times per second
- if ((threadInfo.isHandler() && s_counter % 11 == 0) || s_counter % 499 == 0) {
+ if (((threadInfo.isHandler() || threadInfo.isTaskThread()) && s_counter % 11 == 0) || s_counter % 499 == 0) {
MT->makeThread(houseKeeping, 0);
}
*/
#include "rec-taskqueue.hh"
#include "taskqueue.hh"
+#include "lock.hh"
#include "logger.hh"
#include "stat_t.hh"
#include "syncres.hh"
-static thread_local pdns::TaskQueue t_taskQueue;
+static LockGuarded<pdns::TaskQueue> s_taskQueue;
static pdns::stat_t s_almost_expired_tasks_pushed;
static pdns::stat_t s_almost_expired_tasks_run;
static pdns::stat_t s_almost_expired_tasks_exceptions;
void runTaskOnce(bool logErrors)
{
- t_taskQueue.runOnce(logErrors);
+ s_taskQueue.lock()->runOnce(logErrors);
}
void pushAlmostExpiredTask(const DNSName& qname, uint16_t qtype, time_t deadline)
{
++s_almost_expired_tasks_pushed;
pdns::ResolveTask task{qname, qtype, deadline, true, resolve};
- t_taskQueue.push(std::move(task));
+ s_taskQueue.lock()->push(std::move(task));
}
uint64_t getTaskPushes()
{
- return broadcastAccFunction<uint64_t>([] { return t_taskQueue.getPushes(); });
+ return s_taskQueue.lock()->getPushes();
}
uint64_t getTaskExpired()
{
- return broadcastAccFunction<uint64_t>([] { return t_taskQueue.getExpired(); });
+ return s_taskQueue.lock()->getExpired();
}
uint64_t getTaskSize()
{
- return broadcastAccFunction<uint64_t>([] { return t_taskQueue.getSize(); });
+ return s_taskQueue.lock()->size();
}
uint64_t getAlmostExpiredTasksPushed()
}
}
-uint64_t* TaskQueue::getPushes() const
-{
- return new uint64_t(d_pushes);
-}
-
-uint64_t* TaskQueue::getExpired() const
-{
- return new uint64_t(d_expired);
-}
-
-uint64_t* TaskQueue::getSize() const
-{
- return new uint64_t(size());
-}
-
} /* namespace pdns */
ResolveTask pop();
bool runOnce(bool logErrors); // Run one task if the queue is not empty
void runAll(bool logErrors);
- uint64_t* getPushes() const;
- uint64_t* getExpired() const;
- uint64_t* getSize() const;
+
+ uint64_t getPushes()
+ {
+ return d_pushes;
+ }
+
+ uint64_t getExpired()
+ {
+ return d_expired;
+ }
private:
queue_t d_queue;