Fix: The ping_fail_absolute_limit calculation was incorrect.
authorGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Fri, 20 Jan 2012 10:09:26 +0000 (08:09 -0200)
committerGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
Fri, 20 Jan 2012 10:12:09 +0000 (08:12 -0200)
- The intend of this variable is to provide the maximum number failed
  pings taking in consideration the amount of IP resolved for the host.

src/host/hoststatusanalyzer.cpp

index 1b072d6..93c5e84 100644 (file)
@@ -156,8 +156,15 @@ void HostStatusAnalyzer::analyze_ping_failed_count()
     BOOST_ASSERT( ( 0 <= PingFailPercentageLimit ) && ( PingFailPercentageLimit <= 100 ) );
     BOOST_ASSERT( ( 0 <= PingsFailedCount ) && ( PingsFailedCount <= PingsPerformedCount ) );
 
-    int ping_fail_absolute_limit = PingFailPercentageLimit / 100; // TODO possible precision loss, check with care
+    int ping_fail_absolute_limit = ( ResolvedIpCount * PingFailPercentageLimit ) / 100;
 
     // keep a boolean variable because the PingsFailedCount can be reseted
-    ExceededPingFailedLimit = ( PingsFailedCount > ping_fail_absolute_limit );
+    if ( PingsFailedCount > ping_fail_absolute_limit )
+    {
+        ExceededPingFailedLimit = true;
+    }
+    else
+    {
+        ExceededPingFailedLimit = false;
+    }
 }