if (routingTag) {
auto entries = getEntries(*lockedShard, qname, qtype, routingTag);
- bool found = false;
+ unsigned int found = 0;
time_t ttd{};
if (entries.first != entries.second) {
if (!entryMatches(firstIndexIterator, qtype, requireAuth, who)) {
continue;
}
- found = true;
+ ++found;
handleServeStaleBookkeeping(now, serveStale, firstIndexIterator);
ttd = handleHit(now, *lockedShard, firstIndexIterator, qname, origTTL, res, signatures, authorityRecs, variable, cachedState, wasAuth, fromAuthZone, fromAuthIP);
- if (qtype != QType::ANY && qtype != QType::ADDR) { // normally if we have a hit, we are done
+ if (qtype == QType::ADDR && found == 2) {
+ break;
+ }
+ if (qtype != QType::ANY) { // normally if we have a hit, we are done
break;
}
}
- if (found) {
+ if (found > 0) {
if (cachedState && ttd > now) {
ptrAssign(state, *cachedState);
}
if (entries.first != entries.second) {
OrderedTagIterator_t firstIndexIterator;
- bool found = false;
+ unsigned int found = 0;
time_t ttd{};
for (auto i = entries.first; i != entries.second; ++i) {
if (!entryMatches(firstIndexIterator, qtype, requireAuth, who)) {
continue;
}
- found = true;
+ ++found;
handleServeStaleBookkeeping(now, serveStale, firstIndexIterator);
ttd = handleHit(now, *lockedShard, firstIndexIterator, qname, origTTL, res, signatures, authorityRecs, variable, cachedState, wasAuth, fromAuthZone, fromAuthIP);
- if (qtype != QType::ANY && qtype != QType::ADDR) { // normally if we have a hit, we are done
+ if (qtype == QType::ADDR && found == 2) {
+ break;
+ }
+ if (qtype != QType::ANY) { // normally if we have a hit, we are done
break;
}
}
- if (found) {
+ if (found > 0) {
if (cachedState && ttd > now) {
ptrAssign(state, *cachedState);
}
break;
}
}
+
if (!isNew) {
moveCacheItemToBack<SequencedTag>(lockedShard->d_map, stored);
}