}
}
- if(beenthere.count(answer)) {
+ auto insertionPair = beenthere.insert(std::move(answer));
+ if(!insertionPair.second) {
brokeloop=true;
LOG(prefix<<qname<<": We have NS in cache for '"<<subdomain<<"' but part of LOOP (already seen "<<answer.qname<<")! Trying less specific NS"<<endl);
;
if(doLog())
for( set<GetBestNSAnswer>::const_iterator j=beenthere.begin();j!=beenthere.end();++j) {
- bool neo = !(*j< answer || answer<*j);
+ bool neo = (j == insertionPair.first);
LOG(prefix<<qname<<": beenthere"<<(neo?"*":"")<<": "<<j->qname<<"|"<<DNSRecordContent::NumberToType(j->qtype)<<" ("<<(unsigned int)j->bestns.size()<<")"<<endl);
}
bestns.clear();
}
else {
- beenthere.insert(answer);
LOG(prefix<<qname<<": We have NS in cache for '"<<subdomain<<"' (flawedNSSet="<<*flawedNSSet<<")"<<endl);
return;
}
SyncRes::domainmap_t::const_iterator SyncRes::getBestAuthZone(DNSName* qname) const
{
+ if (t_sstorage.domainmap->empty()) {
+ return t_sstorage.domainmap->end();
+ }
+
SyncRes::domainmap_t::const_iterator ret;
do {
ret=t_sstorage.domainmap->find(*qname);
/** doesn't actually do the work, leaves that to getBestNSFromCache */
DNSName SyncRes::getBestNSNamesFromCache(const DNSName &qname, const QType& qtype, NsSet& nsset, bool* flawedNSSet, unsigned int depth, set<GetBestNSAnswer>&beenthere)
{
- DNSName subdomain(qname);
DNSName authdomain(qname);
domainmap_t::const_iterator iter=getBestAuthZone(&authdomain);
return authdomain;
}
+ DNSName subdomain(qname);
vector<DNSRecord> bestns;
getBestNSFromCache(subdomain, qtype, bestns, flawedNSSet, depth, beenthere);
class RecursorLua4;
-typedef map<
+typedef std::unordered_map<
DNSName,
pair<
vector<ComboAddress>,
ComboAddress d_best;
};
- typedef map<DNSName, DecayingEwmaCollection> nsspeeds_t;
+ typedef std::unordered_map<DNSName, DecayingEwmaCollection> nsspeeds_t;
typedef map<ComboAddress, EDNSStatus> ednsstatus_t;
vState getDSRecords(const DNSName& zone, dsmap_t& ds, bool onlyTA, unsigned int depth, bool bogusOnNXD=true, bool* foundCut=nullptr);
void addSOA(std::vector<DNSRecord>& records) const;
};
- typedef map<DNSName, AuthDomain> domainmap_t;
+ typedef std::unordered_map<DNSName, AuthDomain> domainmap_t;
typedef Throttle<boost::tuple<ComboAddress,DNSName,uint16_t> > throttle_t;
typedef Counters<ComboAddress> fails_t;
{
DNSName qname;
set<pair<DNSName,DNSName> > bestns;
- uint8_t qtype; // only A and AAAA anyhow
+ uint8_t qtype;
bool operator<(const GetBestNSAnswer &b) const
{
- return boost::tie(qname, qtype, bestns) <
- boost::tie(b.qname, b.qtype, b.bestns);
+ return boost::tie(qtype, qname, bestns) <
+ boost::tie(b.qtype, b.qname, b.bestns);
}
};