]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Move sampling-related Ring methods to header 16768/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 26 Jan 2026 13:38:57 +0000 (14:38 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 26 Jan 2026 13:38:57 +0000 (14:38 +0100)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
pdns/dnsdistdist/dnsdist-rings.cc
pdns/dnsdistdist/dnsdist-rings.hh

index 9f1231c30e6e72185d4cf455732e9f463219c645..4eeae568ef21b16598ec76b5dfe143be1824da67 100644 (file)
@@ -204,30 +204,3 @@ bool Rings::Response::isACacheHit() const
   }
   return hit;
 }
-
-bool Rings::shouldSkipQueryDueToSampling()
-{
-  if (d_samplingRate == 0) {
-    return false;
-  }
-  auto counter = t_samplingQueryCounter++;
-  return (counter % d_samplingRate) != 0;
-}
-
-bool Rings::shouldSkipResponseDueToSampling()
-{
-  if (d_samplingRate == 0) {
-    return false;
-  }
-  auto counter = t_samplingResponseCounter++;
-  return (counter % d_samplingRate) != 0;
-}
-
-uint32_t Rings::adjustForSamplingRate(uint32_t count) const
-{
-  const auto samplingRate = getSamplingRate();
-  if (samplingRate > 0) {
-    return count * samplingRate;
-  }
-  return count;
-}
index a07a04a1583b02576bc8d7bf8d2bffaf2fea5d4a..74db1d780c1785af2d854751815d98ebbe1a05f0 100644 (file)
@@ -245,7 +245,14 @@ struct Rings
     return d_samplingRate;
   }
 
-  uint32_t adjustForSamplingRate(uint32_t count) const;
+  uint32_t adjustForSamplingRate(uint32_t count) const
+  {
+    const auto samplingRate = getSamplingRate();
+    if (samplingRate > 0) {
+      return count * samplingRate;
+    }
+    return count;
+  }
 
   std::vector<std::unique_ptr<Shard>> d_shards;
   pdns::stat_t d_blockingQueryInserts{0};
@@ -290,8 +297,23 @@ private:
     return wasFull;
   }
 
-  bool shouldSkipQueryDueToSampling();
-  bool shouldSkipResponseDueToSampling();
+  bool shouldSkipQueryDueToSampling()
+  {
+    if (d_samplingRate == 0) {
+      return false;
+    }
+    auto counter = t_samplingQueryCounter++;
+    return (counter % d_samplingRate) != 0;
+  }
+
+  bool shouldSkipResponseDueToSampling()
+  {
+    if (d_samplingRate == 0) {
+      return false;
+    }
+    auto counter = t_samplingResponseCounter++;
+    return (counter % d_samplingRate) != 0;
+  }
 
   static constexpr bool s_keepLockingStats{false};
   // small hack to reduce contention: this only works because we have a single Rings object in DNSdist