did minor changes; used this version for testing over week-end
[pingcheck] / src / host / pingscheduler.cpp
index 15f10fa..430b5e0 100644 (file)
@@ -170,7 +170,8 @@ void PingScheduler::ping_when_ready()
 {
     if ( !WantToPing )
     {
-        GlobalLogger.info() << LogPrefix << "waiting for ping request";
+        GlobalLogger.info() << LogPrefix << "waiting for ping request "
+            << "(should take less than " << PingIntervalInSec << "s)";
         return;
     }
     else if ( Resolver && Resolver->is_resolving() )
@@ -213,13 +214,18 @@ void PingScheduler::ping_when_ready()
     else
     {
         uint32_t ttl = ip.get_ttl().get_updated_value();
-        boost::posix_time::ptime now =
+        std::string expiry;
+        if (ttl == 0)
+            expiry = "out of date!";
+        else
+        {
+            boost::posix_time::ptime now =
                                   boost::posix_time::second_clock::local_time();
-        std::string expiry =
-                        boost::posix_time::to_simple_string(now + seconds(ttl));
+            expiry = boost::posix_time::to_simple_string(now + seconds(ttl));
+        }
 
         GlobalLogger.info() << LogPrefix << "pinging IP " << ip.get_ip()
-            << " with TTL " << ttl << "s (until " << expiry << ")";
+            << " with TTL " << ttl << "s (" << expiry << ")";
         Ping->ping( ip.get_ip(),
                     DestinationPort,
                     boost::bind(&PingScheduler::ping_done_handler, this, _1) );
@@ -373,12 +379,13 @@ void PingScheduler::update_dns_resolver( PingProtocol current_protocol )
                                                            current_protocol);
 
     // get number of up-to-date IPs
+    // TODO should check here, if they will be up to date in PingIntervalInSec
     bool check_up_to_date = true;
     int ip_count = Resolver->get_resolved_ip_count(check_up_to_date);
     if (ip_count > 0)
     {
         GlobalLogger.info() << LogPrefix << "Set resolved_ip_count to "
-            << ip_count << " where IPs may be outdated: " << false;
+            << ip_count << " where IPs may be outdated: " << !check_up_to_date;
         HostAnalyzer.set_resolved_ip_count( ip_count );
 
         if (Resolver->is_resolving())
@@ -388,8 +395,12 @@ void PingScheduler::update_dns_resolver( PingProtocol current_protocol )
         ping_when_ready();
     }
     else
+    {
+        GlobalLogger.info() << LogPrefix
+                            << "No up-to-date IPs --> start resolve";
         start_resolving_ping_address();
-        // set resolved_ip_count in resolve callback
+        // set resolved_ip_count will be called in resolve callback
+    }
 }
 
 void PingScheduler::start_resolving_ping_address()