*/
void HostStatus::set_resolved_ip_count( const int resolved_ip_count )
{
- BOOST_ASSERT( 1 <= resolved_ip_count );
+ BOOST_ASSERT( 0 <= resolved_ip_count );
if (resolved_ip_count != ResolvedIpCount)
{ // assume that the target has changed --> reset counters
<< "-- treat like a failed ping.";
// skip the ping and directly call ping_done_handler
+ HostAnalyzer.set_resolved_ip_count(1); // must have been 0 --> failed
+ // ping would create failed assumption (nPings > nIPs)
ping_done_handler(false);
+ HostAnalyzer.set_resolved_ip_count(0); // set back
}
else
{
else
{ // host name resolution failed; try again bypassing first outdated CNAME
// or using cached IP
- ContinueOnOutdatedIps = true;
- update_log_prefix();
-
std::string skip_host = Resolver->get_skip_cname();
if (skip_host.empty())
- { // continue with IP
- GlobalLogger.notice() << LogPrefix << "DNS failed, "
- << "try anyway with cached data";
-
+ { // try to continue with cached IPs
int ip_count = Resolver->get_resolved_ip_count(false);
+
+ if (ip_count == 0)
+ GlobalLogger.notice() << LogPrefix << "DNS failed "
+ << "and have no cached IPs either --> cannot ping";
+ // ping_when_ready will deal with this case
+ else
+ {
+ ContinueOnOutdatedIps = true;
+ update_log_prefix();
+
+ GlobalLogger.notice() << LogPrefix << "DNS failed, "
+ << "try anyway with cached data";
+ }
+
GlobalLogger.info() << LogPrefix << "Set resolved_ip_count to "
<< ip_count << " (IPs may be outdated=" << true << ")";
HostAnalyzer.set_resolved_ip_count( ip_count );
}
else
{ // have CNAME to continue
+ ContinueOnOutdatedIps = true;
+ update_log_prefix();
GlobalLogger.notice() << LogPrefix << "DNS failed, "
<< "try again skipping a CNAME and resolving "
<< skip_host << " directly";