Fixed burnt logic: Only check for burnt IP address if there are at least max_equal_up...
authorBjoern Sikora <bjoern.sikora@intra2net.com>
Fri, 28 Jan 2011 17:22:02 +0000 (18:22 +0100)
committerBjoern Sikora <bjoern.sikora@intra2net.com>
Fri, 28 Jan 2011 17:22:02 +0000 (18:22 +0100)
src/updater.cpp

index 2922cb7..d7bbef3 100644 (file)
@@ -248,10 +248,16 @@ void Updater::update_services(bool changed_to_online) const
         // Try to get the lastupdated time of the actual service if there is one.
         // And check for burnt IP, too.
         std::map<time_t,std::string> last_updates = service->get_last_updates(); /*lint !e1793 */
-        if ( last_updates.size() > 0 )
+
+        int last_updates_size = last_updates.size();
+        int max_equal_updates_in_succession = service->get_max_equal_updates_in_succession();
+
+        Log->print_last_updates(ip_host,max_equal_updates_in_succession,last_updates,service->get_hostname());
+
+        // Only check for burnt IP address if there are at least max_equal_updates_in_succession entries in the last_updates map.
+        if ( (max_equal_updates_in_succession != 0) && (last_updates_size >= max_equal_updates_in_succession) )
         {
             bool ip_burnt = true;
-            int max_equal_updates_in_succession = service->get_max_equal_updates_in_succession();
             int i = 0;
             for ( std::map<time_t,std::string>::reverse_iterator r_iter = last_updates.rbegin(); (r_iter != last_updates.rend()) && (i < max_equal_updates_in_succession); r_iter++ )
             {
@@ -267,8 +273,6 @@ void Updater::update_services(bool changed_to_online) const
                 i++;
             }
 
-            Log->print_last_updates(ip_host,max_equal_updates_in_succession,last_updates,service->get_hostname());
-
             if ( ip_burnt )
             {
                 // IP Address is burnt. Too many updates in succession with the same IP.