X-Git-Url: http://developer.intra2net.com/git/?a=blobdiff_plain;f=src%2Fservice.cpp;h=a8b52c62a6d9cb4e54f4b31474195d697052095b;hb=0ebcd4efc05fa4e11e9e7b2166a15a84c884bd45;hp=dcc7fa1d76195bb4eb39bfbdd008a2e1e4dac818;hpb=80b0e508f15731974f77af17496991defdcf9e90;p=bpdyndnsd diff --git a/src/service.cpp b/src/service.cpp index dcc7fa1..a8b52c6 100644 --- a/src/service.cpp +++ b/src/service.cpp @@ -207,9 +207,10 @@ bool Service::operator!= (const Service& other) const /** * Checks if update will exceed max update interval. * @param current_time Current time. + * @param changed_to_online True if we just changed to online, false if we were already online * @return True if update is allowed, false if update would exceed max update interval. */ -bool Service::update_allowed(const time_t current_time) +bool Service::update_allowed(const time_t current_time, bool changed_to_online) { list::iterator iter; int i=0; @@ -218,7 +219,7 @@ bool Service::update_allowed(const time_t current_time) { if ( (i == (MaxUpdatesWithinInterval-1)) && ( (*iter + ((time_t)UpdateInterval*60)) >= current_time ) ) { - Log->print_update_not_allowed(current_time,*iter,MaxUpdatesWithinInterval,get_service_name()); + Log->print_update_not_allowed(changed_to_online, current_time,*iter,MaxUpdatesWithinInterval,get_service_name()); return false; } i++; @@ -230,8 +231,10 @@ bool Service::update_allowed(const time_t current_time) /** * Service update method, common to each service. * @param ip The new ip to set for the hostname. + * @param current_time Current time + * @param changed_to_online True if we just changed to online, false if we were already online */ -void Service::update(const string& ip, const time_t current_time) +void Service::update(const string& ip, const time_t current_time, bool changed_to_online) { const std::string service_name = get_service_name(); @@ -242,11 +245,11 @@ void Service::update(const string& ip, const time_t current_time) return; } - Log->print_update_service(service_name); - // test if update is permitted by UpdateInterval Status - if ( update_allowed(current_time) ) + if ( update_allowed(current_time, changed_to_online) ) { + Log->print_update_service(service_name); + if ( perform_update(ip) == 0 ) { // if update was successful, we need to set the Lastupdated and ActualIP base member.