From: Thomas Jarosch Date: Mon, 31 Jan 2011 10:58:43 +0000 (+0100) Subject: As we want to delete to oldest entry, we can use begin() instead of upper_bound(0) X-Git-Tag: v1.1~19 X-Git-Url: http://developer.intra2net.com/git/?p=bpdyndnsd;a=commitdiff_plain;h=3401630006877f53014bef05373bfe680f02a908 As we want to delete to oldest entry, we can use begin() instead of upper_bound(0) --- 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; } }