GlobalLogger.debug() << log_prefix() << "add ping with result "
<< to_string(result) << " which took " << ping_duration_ms << " ms";
- BOOST_ASSERT( 1 <= ResolvedIpCount );
+ BOOST_ASSERT( 0 <= ResolvedIpCount );
BOOST_ASSERT( 0 <= PingsPerformedCount );
BOOST_ASSERT( PingsFailedCount <= PingsPerformedCount );
BOOST_ASSERT( PingCongestionCount <= PingsPerformedCount );
bool HostStatus::tried_all_resolved_ip() const
{
- BOOST_ASSERT( ( 0 < PingsPerformedCount ) &&
- ( PingsPerformedCount <= ResolvedIpCount*NParallelPingers ) );
+ BOOST_ASSERT( 0 < PingsPerformedCount );
- return ( PingsPerformedCount == ResolvedIpCount*NParallelPingers );
+ return ( PingsPerformedCount >= ResolvedIpCount*NParallelPingers );
}
void HostStatus::analyze_ping_statistics()
{
BOOST_ASSERT( !HostAddress.empty() );
- BOOST_ASSERT( PingsPerformedCount == ResolvedIpCount*NParallelPingers );
+ BOOST_ASSERT( PingsPerformedCount >= ResolvedIpCount*NParallelPingers );
// notify if the amount of pings that failed exceed the limit
if ( exceeded_ping_failed_limit() )
{
++PingsPerformedCount;
- BOOST_ASSERT( ( 0 < PingsPerformedCount ) &&
- ( PingsPerformedCount <= ResolvedIpCount*NParallelPingers ) );
+ BOOST_ASSERT( 0 < PingsPerformedCount );
}
void HostStatus::increase_ping_failed_count()
GlobalLogger.info() << LogPrefix << "Not even outdated IP to ping "
<< "-- 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(PingStatus_FailureNoIP, 0);
- HostAnalyzer.set_resolved_ip_count(0); // set back
+ // skip the ping and directly call ping_done_handler the appropriate
+ // number of times
+ for (int count=0; count<NPingers; ++count)
+ ping_done_handler(PingStatus_FailureNoIP, 0);
}
else
{
boost::asio::ip::address actual_ip = ip.get_ip();
GlobalLogger.info() << LogPrefix << "pinging IP " << actual_ip
<< " with TTL " << ip.get_ttl().get_updated_value() << "s";
- NPingersDone = 0;
delayed_ping(boost::system::error_code(), actual_ip, 0);
}
}
// start DNS resolve if necessary
update_dns_resolver();
+ NPingersDone = 0;
+
// schedule next ping
int seconds_since_last_ping = (microsec_clock::universal_time()
- TimeSentLastPing).total_seconds();
// trust that a successfull DNS resolve means we have an IP with TTL>0
int ip_count = Resolver->get_resolved_ip_count(!ContinueOnOutdatedIps);
if (ip_count == 0)
- { // this will create trouble in HostAnalyzer
+ {
GlobalLogger.warning() << LogPrefix
<< "Should not have reached this case: resolve was "
<< "successfull but still have no IPs (up-to-date="
GlobalLogger.info() << LogPrefix << "Set resolved_ip_count to "
<< ip_count << " (IPs may be outdated="
<< ContinueOnOutdatedIps << ") --> could ping now";
- HostAnalyzer.set_resolved_ip_count( ip_count );
}
+ HostAnalyzer.set_resolved_ip_count( ip_count );
ping_when_ready();
}
else