From 3401630006877f53014bef05373bfe680f02a908 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Mon, 31 Jan 2011 11:58:43 +0100 Subject: [PATCH] As we want to delete to oldest entry, we can use begin() instead of upper_bound(0) --- src/service.cpp | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/service.cpp b/src/service.cpp index 57071fb..3c1cd25 100644 --- a/src/service.cpp +++ b/src/service.cpp @@ -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; } } -- 1.7.1