From: Remi Gacogne Date: Thu, 2 Nov 2017 13:54:46 +0000 (+0100) Subject: rec: Purge nsSpeeds entries even if we get less than 2 new entries X-Git-Tag: auth-4.1.0-rc3~37^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c767798a4b1561bbb3d5462d0467d54b6b062aea;p=pdns rec: Purge nsSpeeds entries even if we get less than 2 new entries --- diff --git a/pdns/syncres.cc b/pdns/syncres.cc index 504aa61ce..5795cbf03 100644 --- a/pdns/syncres.cc +++ b/pdns/syncres.cc @@ -685,17 +685,21 @@ vector SyncRes::getAddrs(const DNSName &qname, unsigned int depth, d_requireAuthData = oldRequireAuthData; d_DNSSECValidationRequested = oldValidationRequested; - if(ret.size() > 1) { - map speeds; - auto& collection = t_sstorage.nsSpeeds[qname].d_collection; - for(const auto& val: ret) { - double speed; - speed=collection[val].get(&d_now); - speeds[val]=speed; - } + /* we need to remove from the nsSpeeds collection the existing IPs + for this nameserver that are no longer in the set, even if there + is only one or none at all in the current set. + */ + map speeds; + auto& collection = t_sstorage.nsSpeeds[qname].d_collection; + for(const auto& val: ret) { + double speed; + speed=collection[val].get(&d_now); + speeds[val]=speed; + } - t_sstorage.nsSpeeds[qname].purge(speeds); + t_sstorage.nsSpeeds[qname].purge(speeds); + if(ret.size() > 1) { random_shuffle(ret.begin(), ret.end(), dns_random); speedOrderCA so(speeds); stable_sort(ret.begin(), ret.end(), so);