void pushAlmostExpiredTask(const DNSName& qname, uint16_t qtype, time_t deadline)
{
pdns::ResolveTask task{qname, qtype, deadline, true, resolve};
- auto lock = s_taskQueue.lock();
- bool running = !lock->rateLimitSet.insert(time(nullptr), task);
- if (!running) {
- ++s_almost_expired_tasks.pushed;
- lock->queue.push(std::move(task));
- }
+ s_taskQueue.lock()->queue.push(std::move(task));
+ ++s_almost_expired_tasks.pushed;
}
-void pushResolveTask(const DNSName& qname, uint16_t qtype, time_t deadline)
+void pushResolveTask(const DNSName& qname, uint16_t qtype, time_t now, time_t deadline)
{
pdns::ResolveTask task{qname, qtype, deadline, false, resolve};
auto lock = s_taskQueue.lock();
- bool running = !lock->rateLimitSet.insert(time(nullptr), task);
- if (!running) {
- ++s_resolve_tasks.pushed;
+ bool inserted = lock->rateLimitSet.insert(now, task);
+ if (inserted) {
lock->queue.push(std::move(task));
+ ++s_resolve_tasks.pushed;
}
}
void runTaskOnce(bool logErrors);
void pushAlmostExpiredTask(const DNSName& qname, uint16_t qtype, time_t deadline);
-void pushResolveTask(const DNSName& qname, uint16_t qtype, time_t deadline);
+void pushResolveTask(const DNSName& qname, uint16_t qtype, time_t now, time_t deadline);
// General task stats
uint64_t getTaskPushes();
uint16_t d_qtype;
time_t d_deadline;
bool d_refreshMode; // Whether to run this task in regular mode (false) or in the mode that refreshes almost expired tasks
- // Use a function ponter as comparing std::functions is a nuisance
+ // Use a function pointer as comparing std::functions is a nuisance
void (*d_func)(const struct timeval& now, bool logErrors, const ResolveTask& task);
bool operator<(const ResolveTask& a) const
g_test_tasks.push({qname, qtype, deadline, true, nullptr});
}
-void pushResolveTask(const DNSName& qname, uint16_t qtype, time_t deadline)
+void pushResolveTask(const DNSName& qname, uint16_t qtype, time_t now, time_t deadline)
{
}
}
if (s_doIPv6) { // s_doIPv6 **IMPLIES** pdns::isQueryLocalAddressFamilyEnabled(AF_INET6) returned true
if (ret.empty()) {
- // We only go out imediately to find IPv6 records if we did not find any IPv4 ones.
+ // We only go out immediately to find IPv6 records if we did not find any IPv4 ones.
newState = vState::Indeterminate;
cset.clear();
if (doResolve(qname, QType::AAAA, cset, depth+1, beenthere, newState) == 0) { // this consults cache, OR goes out
}
}
if (s_doIPv6 && !seenV6 && !cacheOnly) {
- // No IPv6 NS records in cache, chek negcache and submit async task if negache does not have the data
+ // No IPv6 records in cache, check negcache and submit async task if negache does not have the data
// so that the next time the cache or the negcache will have data
NegCache::NegCacheEntry ne;
bool inNegCache = g_negCache->get(qname, QType::AAAA, d_now, ne, true);
if (!inNegCache) {
- pushResolveTask(qname, QType::AAAA, d_now.tv_sec + 60);
+ pushResolveTask(qname, QType::AAAA, d_now.tv_sec, d_now.tv_sec + 60);
}
}
}
- catch (const PolicyHitException& e) {
- /* we ignore a policy hit while trying to retrieve the addresses
- of a NS and keep processing the current query */
+ catch (const PolicyHitException&) {
+ // We ignore a policy hit while trying to retrieve the addresses
+ // of a NS and keep processing the current query
}
if (ret.empty() && d_outqueries > startqueries) {