]> granicus.if.org Git - pdns/commitdiff
Constify rnameservers
authorphonedph1 <phoned@gmail.com>
Fri, 12 Jan 2018 16:20:37 +0000 (16:20 +0000)
committerphonedph1 <phoned@gmail.com>
Fri, 12 Jan 2018 16:20:37 +0000 (16:20 +0000)
pdns/syncres.cc
pdns/syncres.hh

index 67b88822864db3e5438c1748118f31e6fef592b0..e39ae17999e5ba0729354ee2ac6ea4b76f9c0718 100644 (file)
@@ -1282,26 +1282,27 @@ inline vector<DNSName> SyncRes::shuffleInSpeedOrder(NsSet &tnameservers, const s
   return rnameservers;
 }
 
-inline vector<ComboAddress> SyncRes::shuffleForwardSpeed(vector<ComboAddress> &rnameservers, const string &prefix, const bool wasRd)
+inline vector<ComboAddress> SyncRes::shuffleForwardSpeed(const vector<ComboAddress> &rnameservers, const string &prefix, const bool wasRd)
 {
+  vector<ComboAddress> nameservers = rnameservers;
   map<ComboAddress, double> speeds;
 
-  for(const auto& val: rnameservers) {
+  for(const auto& val: nameservers) {
     double speed;
     DNSName nsName = DNSName(val.toStringWithPort());
     speed=t_sstorage.nsSpeeds[nsName].get(&d_now);
     speeds[val]=speed;
   }
-  random_shuffle(rnameservers.begin(),rnameservers.end(), dns_random);
+  random_shuffle(nameservers.begin(),nameservers.end(), dns_random);
   speedOrderCA so(speeds);
-  stable_sort(rnameservers.begin(),rnameservers.end(), so);
+  stable_sort(nameservers.begin(),nameservers.end(), so);
 
   if(doLog()) {
     LOG(prefix<<"Nameservers: ");
-    for(vector<ComboAddress>::const_iterator i=rnameservers.cbegin();i!=rnameservers.cend();++i) {
-      if(i!=rnameservers.cbegin()) {
+    for(vector<ComboAddress>::const_iterator i=nameservers.cbegin();i!=nameservers.cend();++i) {
+      if(i!=nameservers.cbegin()) {
         LOG(", ");
-        if(!((i-rnameservers.cbegin())%3)) {
+        if(!((i-nameservers.cbegin())%3)) {
           LOG(endl<<prefix<<"             ");
         }
       }
@@ -1309,7 +1310,7 @@ inline vector<ComboAddress> SyncRes::shuffleForwardSpeed(vector<ComboAddress> &r
     }
     LOG(endl);
   }
-  return rnameservers;
+  return nameservers;
 }
 
 static uint32_t getRRSIGTTL(const time_t now, const std::shared_ptr<RRSIGRecordContent>& rrsig)
index 702c27486641f7064cbaf34f1a3aa3511a916860..738d18fa7074bbdff5a1ee4a5702fa424d3171df 100644 (file)
@@ -739,7 +739,7 @@ private:
   DNSName getBestNSNamesFromCache(const DNSName &qname, const QType &qtype, NsSet& nsset, bool* flawedNSSet, unsigned int depth, set<GetBestNSAnswer>&beenthere);
 
   inline vector<DNSName> shuffleInSpeedOrder(NsSet &nameservers, const string &prefix);
-  inline vector<ComboAddress> shuffleForwardSpeed(vector<ComboAddress> &rnameservers, const string &prefix, const bool wasRd);
+  inline vector<ComboAddress> shuffleForwardSpeed(const vector<ComboAddress> &rnameservers, const string &prefix, const bool wasRd);
   bool moreSpecificThan(const DNSName& a, const DNSName &b) const;
   vector<ComboAddress> getAddrs(const DNSName &qname, unsigned int depth, set<GetBestNSAnswer>& beenthere, bool cacheOnly);