From be67763ad8f396a3d336bec93fb902a58783e3a4 Mon Sep 17 00:00:00 2001
From: Remi Gacogne <remi.gacogne@powerdns.com>
Date: Thu, 29 Mar 2018 11:34:07 +0200
Subject: [PATCH] dnsdist: Comment that the rings shouldn't be resized at
 run-time

---
 pdns/dnsdist-rings.hh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/pdns/dnsdist-rings.hh b/pdns/dnsdist-rings.hh
index f9810efad..0ff9a1ec9 100644
--- a/pdns/dnsdist-rings.hh
+++ b/pdns/dnsdist-rings.hh
@@ -71,6 +71,7 @@ struct Rings {
   }
   std::unordered_map<int, vector<boost::variant<string,double> > > getTopBandwidth(unsigned int numentries);
   size_t numDistinctRequestors();
+  /* This function should only be called at configuration time before any query or response has been inserted */
   void setCapacity(size_t newCapacity, size_t numberOfShards)
   {
     if (numberOfShards < d_numberOfShards) {
@@ -92,6 +93,10 @@ struct Rings {
         shard->respRing.set_capacity(newCapacity / numberOfShards);
       }
     }
+
+    /* we just recreated the shards so they are now empty */
+    d_nbQueryEntries = 0;
+    d_nbResponseEntries = 0;
   }
 
   void setNumberOfLockRetries(size_t retries)
-- 
2.40.0