From: phonedph1 Date: Thu, 11 Jan 2018 15:04:50 +0000 (+0000) Subject: Use speedOrderCA and be slightly less abusive on the amount of conversions done. X-Git-Tag: dnsdist-1.3.0~129^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6ed0c28aecc3c6d05c1e92c0e939794899deca87;p=thirdparty%2Fpdns.git Use speedOrderCA and be slightly less abusive on the amount of conversions done. --- diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 2a1137f7ed..67b8882286 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -1282,43 +1282,34 @@ inline vector SyncRes::shuffleInSpeedOrder(NsSet &tnameservers, const s return rnameservers; } -inline vector SyncRes::shuffleForwardSpeed(vector &nameservers, const string &prefix, const bool wasRd) +inline vector SyncRes::shuffleForwardSpeed(vector &rnameservers, const string &prefix, const bool wasRd) { - vector out_nameservers; - vector rnameservers; - for(const auto& ns:nameservers) { - rnameservers.push_back(DNSName(ns.toStringWithPort())); - } - - map speeds; + map speeds; for(const auto& val: rnameservers) { double speed; - speed=t_sstorage.nsSpeeds[val].get(&d_now); + DNSName nsName = DNSName(val.toStringWithPort()); + speed=t_sstorage.nsSpeeds[nsName].get(&d_now); speeds[val]=speed; } random_shuffle(rnameservers.begin(),rnameservers.end(), dns_random); - speedOrder so(speeds); + speedOrderCA so(speeds); stable_sort(rnameservers.begin(),rnameservers.end(), so); - for(vector::const_iterator i=rnameservers.cbegin();i!=rnameservers.cend();++i) { - out_nameservers.push_back(ComboAddress(i->toStringNoDot())); - } - if(doLog()) { LOG(prefix<<"Nameservers: "); - for(vector::const_iterator i=rnameservers.cbegin();i!=rnameservers.cend();++i) { + for(vector::const_iterator i=rnameservers.cbegin();i!=rnameservers.cend();++i) { if(i!=rnameservers.cbegin()) { LOG(", "); if(!((i-rnameservers.cbegin())%3)) { LOG(endl<toStringNoDot() <<"(" << (boost::format("%0.2f") % (speeds[*i]/1000.0)).str() <<"ms)"); + LOG((wasRd ? string("+") : string("-")) << i->toStringWithPort() <<"(" << (boost::format("%0.2f") % (speeds[*i]/1000.0)).str() <<"ms)"); } LOG(endl); } - return out_nameservers; + return rnameservers; } static uint32_t getRRSIGTTL(const time_t now, const std::shared_ptr& rrsig) diff --git a/pdns/syncres.hh b/pdns/syncres.hh index 89346906a2..702c274866 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -739,7 +739,7 @@ private: DNSName getBestNSNamesFromCache(const DNSName &qname, const QType &qtype, NsSet& nsset, bool* flawedNSSet, unsigned int depth, set&beenthere); inline vector shuffleInSpeedOrder(NsSet &nameservers, const string &prefix); - inline vector shuffleForwardSpeed(vector &nameservers, const string &prefix, const bool wasRd); + inline vector shuffleForwardSpeed(vector &rnameservers, const string &prefix, const bool wasRd); bool moreSpecificThan(const DNSName& a, const DNSName &b) const; vector getAddrs(const DNSName &qname, unsigned int depth, set& beenthere, bool cacheOnly);