As we want to delete to oldest entry, we can use begin() instead of upper_bound(0)
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Mon, 31 Jan 2011 10:58:43 +0000 (11:58 +0100)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Mon, 31 Jan 2011 10:58:43 +0000 (11:58 +0100)
src/service.cpp

index 57071fb..3c1cd25 100644 (file)
@@ -296,22 +296,22 @@ void Service::set_last_update(const time_t current_time, const string& ip)
     {
         // Delete the oldest entry if there are more than max(MaxUpdatesWithinInterval,MaxEqualUpdatesInSuccession)+1 entries in the list.
         if ( LastUpdates.size() > (size_t)(maximum+1) )
-            LastUpdates.erase(LastUpdates.upper_bound(0));
+            LastUpdates.erase(LastUpdates.begin());
         return;
     }
     // UpdateInterval given in service config, then use this to check for expired entries.
     else if ( UpdateInterval > 0 )
     {
         // Delete the oldest entry if it's older than current_time - UpdateInterval(minutes) + 1.
-        if ( (current_time - ((time_t)UpdateInterval*60) + 1) > LastUpdates.upper_bound(0)->first )
-            LastUpdates.erase(LastUpdates.upper_bound(0));
+        if ( (current_time - ((time_t)UpdateInterval*60) + 1) > LastUpdates.begin()->first )
+            LastUpdates.erase(LastUpdates.begin());
         return;
     }
     // Neither MaxUpdatesWithinInterval nor UpdateInterval are given, so keep fix number of 10 entries.
     else
     {
         if ( LastUpdates.size() > 10 )
-            LastUpdates.erase(LastUpdates.upper_bound(0));
+            LastUpdates.erase(LastUpdates.begin());
         return;
     }
 }