From ffa5cfe241f2422f8028132a592d2455c95c4516 Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Tue, 26 May 2015 17:50:33 +0200 Subject: [PATCH] removed assertion in HostStatus that PingsPerformedCount <= ResolvedIpCount*NParallelPingers because that required some hacks in case we have no IP and call the ping_done_handler --- CMakeLists.txt | 2 +- src/host/hoststatus.cpp | 12 +++++------- src/host/pingscheduler.cpp | 16 ++++++++-------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ff46fd..b765f72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # project: definitions project(pingcheck) set(VERSION 0.5) -set(VERSION_REVISION 1) +set(VERSION_REVISION 2) set(TARGET ${PROJECT_NAME}) # cmake: build options diff --git a/src/host/hoststatus.cpp b/src/host/hoststatus.cpp index 7904bd1..7449a91 100644 --- a/src/host/hoststatus.cpp +++ b/src/host/hoststatus.cpp @@ -144,7 +144,7 @@ void HostStatus::update_ping_statistics( const PingStatus &result, 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 ); @@ -196,16 +196,15 @@ void HostStatus::update_congestion_stats( const PingStatus &result, 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() ) @@ -234,8 +233,7 @@ void HostStatus::increase_ping_performed_count() { ++PingsPerformedCount; - BOOST_ASSERT( ( 0 < PingsPerformedCount ) && - ( PingsPerformedCount <= ResolvedIpCount*NParallelPingers ) ); + BOOST_ASSERT( 0 < PingsPerformedCount ); } void HostStatus::increase_ping_failed_count() diff --git a/src/host/pingscheduler.cpp b/src/host/pingscheduler.cpp index 7b06778..5e2707a 100644 --- a/src/host/pingscheduler.cpp +++ b/src/host/pingscheduler.cpp @@ -244,11 +244,10 @@ void PingScheduler::ping_when_ready() 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; count0 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=" @@ -546,8 +546,8 @@ void PingScheduler::dns_resolve_callback(const bool was_success, 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 -- 1.7.1