]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Cleanup UeberBackend cache handling methods
authorFred Morcos <fred.morcos@open-xchange.com>
Fri, 27 Oct 2023 22:05:16 +0000 (00:05 +0200)
committerFred Morcos <fred.morcos@open-xchange.com>
Sun, 29 Oct 2023 14:04:26 +0000 (15:04 +0100)
pdns/ueberbackend.cc
pdns/ueberbackend.hh

index 40584a5321a29748da18fbb75417b5511f46e88a..fd51010bb1d2396b321beed2c02151bdd37e2bf0 100644 (file)
@@ -588,11 +588,11 @@ void UeberBackend::cleanup()
 }
 
 // returns -1 for miss, 0 for negative match, 1 for hit
-int UeberBackend::cacheHas(const Question& q, vector<DNSZoneRecord>& rrs)
+int UeberBackend::cacheHas(const Question& q, vector<DNSZoneRecord>& rrs) const
 {
   extern AuthQueryCache QC;
 
-  if (!d_cache_ttl && !d_negcache_ttl) {
+  if (d_cache_ttl == 0 && d_negcache_ttl == 0) {
     return -1;
   }
 
@@ -603,31 +603,35 @@ int UeberBackend::cacheHas(const Question& q, vector<DNSZoneRecord>& rrs)
   if (!ret) {
     return -1;
   }
-  if (rrs.empty()) // negatively cached
+  if (rrs.empty()) // negatively cached
     return 0;
+  }
 
   return 1;
 }
 
-void UeberBackend::addNegCache(const Question& q)
+void UeberBackend::addNegCache(const Question& q) const
 {
   extern AuthQueryCache QC;
-  if (!d_negcache_ttl)
+  if (d_negcache_ttl == 0) {
     return;
+  }
   // we should also not be storing negative answers if a pipebackend does scopeMask, but we can't pass a negative scopeMask in an empty set!
   QC.insert(q.qname, q.qtype, vector<DNSZoneRecord>(), d_negcache_ttl, q.zoneId);
 }
 
-void UeberBackend::addCache(const Question& q, vector<DNSZoneRecord>&& rrs)
+void UeberBackend::addCache(const Question& q, vector<DNSZoneRecord>&& rrs) const
 {
   extern AuthQueryCache QC;
 
-  if (!d_cache_ttl)
+  if (d_cache_ttl == 0) {
     return;
+  }
 
   for (const auto& rr : rrs) {
-    if (rr.scopeMask)
+    if (rr.scopeMask) {
       return;
+    }
   }
 
   QC.insert(q.qname, q.qtype, std::move(rrs), d_cache_ttl, q.zoneId);
index 19b1001fbbed71f506c6133d02dfc66a630f0248..04785d1adbb945b7f7d07d2c32e51beafdb1676d 100644 (file)
@@ -165,7 +165,7 @@ private:
   bool d_stale;
   static bool s_doANYLookupsOnly;
 
-  int cacheHas(const Question& q, vector<DNSZoneRecord>& rrs);
-  void addNegCache(const Question& q);
-  void addCache(const Question& q, vector<DNSZoneRecord>&& rrs);
+  int cacheHas(const Question& q, vector<DNSZoneRecord>& rrs) const;
+  void addNegCache(const Question& q) const;
+  void addCache(const Question& q, vector<DNSZoneRecord>&& rrs) const;
 };