}
/**
- * from a list of CNAMEs find the first one that is out of date
+ * from a list of CNAMEs find the first one that is out of date or empty
+ *
+ * returns the hostname that is out of date or empty if all CNAMEs are
+ * up-to-date
*
* required in ResolverBase::get_skipper
- *
- * Assume you have the following situation in cache with TTLs below:
- * hostname --> cname1 --> cname2 --> ... --> cnameN [--> IP]
- * 100 0 --> return cname2
- * 100 100 100 100 --> return cnameN
- * ( with N < Config::MaxRetrievalRecursions )
- * hostname --> IP (no cnames involved) --> return hostname
*/
std::string DnsCache::get_first_outdated_cname(const std::string &hostname,
const uint32_t ttl_thresh)
{
GlobalLogger.warning() << "DnsCache: reached recursion limit of "
<< n_recursions << " in search of outdated CNAMEs!";
- break;
- }
+ return first_outdated; // not really out of date but currently
+ } // our best guess
cname = get_cname(first_outdated);
if (cname.Host.empty())
- // reached end of cname list
- break;
+ // reached end of cname list --> everything was up-to-date
+ return "";
else if (cname.Ttl.get_updated_value() > ttl_thresh)
// cname is up to date --> continue looking
first_outdated = cname.Host;
else
- { // cname is out of date --> return its target
- first_outdated = cname.Host;
- break;
- }
+ // cname is out of date --> return its target
+ return cname.Host;
}
- return first_outdated;
+ // reach this point only if cname chain does not end with an IP
+ // --> all are up-to-date
+ return "";
}
// (created using vim -- the world's best text editor)