]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Don't rate limit refresh tasks, they are already rate limited by packet and record...
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Thu, 17 Feb 2022 14:43:55 +0000 (15:43 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Thu, 17 Feb 2022 14:56:54 +0000 (15:56 +0100)
pdns/recursordist/rec-taskqueue.cc
pdns/recursordist/rec-taskqueue.hh
pdns/recursordist/taskqueue.hh
pdns/recursordist/test-syncres_cc.cc
pdns/syncres.cc

index f59a3505150c596ee8af021e2b238aab9dc3b319..99a50fb5365b1547fcd5cf5212ca5590a845a796 100644 (file)
@@ -167,22 +167,18 @@ void runTaskOnce(bool logErrors)
 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;
   }
 }
 
index b33e2abc51ec1cb5c61fdad72c2e254dfe4e6061..c1e664a4afa1989b475e29c375f0cd9bc75e1a6f 100644 (file)
@@ -28,7 +28,7 @@ class DNSName;
 
 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();
index abdd768439c403123a969e507ba0ac1e0aea1103..b677fab30cff0305890ac317f6b9e23d3292881d 100644 (file)
@@ -45,7 +45,7 @@ struct ResolveTask
   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
index 6cc890037240f2a5deac45e8c421f00dbcf89524..6ead553219bf2014d14f17bbacc329b6a02e2ad7 100644 (file)
@@ -559,6 +559,6 @@ void pushAlmostExpiredTask(const DNSName& qname, uint16_t qtype, time_t deadline
   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)
 {
 }
index 11973c56e40e1691d3f973a3e7fb87d6e5971b0f..54f45b1378b67fbe0b9ab5224ad4291e0d59e9ae 100644 (file)
@@ -1177,7 +1177,7 @@ vector<ComboAddress> SyncRes::getAddrs(const DNSName &qname, unsigned int depth,
       }
       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
@@ -1205,18 +1205,18 @@ vector<ComboAddress> SyncRes::getAddrs(const DNSName &qname, unsigned int depth,
       }
     }
     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) {