From 3fdee948ec5f043654dd97b0bdfb368baa94dcf5 Mon Sep 17 00:00:00 2001 From: Thomas Jarosch Date: Wed, 6 Oct 2010 14:51:18 +0200 Subject: [PATCH] Save one more indent/if level --- src/updater.cpp | 52 +++++++++++++++++++++++++--------------------------- 1 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/updater.cpp b/src/updater.cpp index 81e277e..cbd93a9 100644 --- a/src/updater.cpp +++ b/src/updater.cpp @@ -249,50 +249,48 @@ void Updater::update_services() const // Test if the DNS-Record could not be found. if ( ip_dns_recheck.empty() ) + continue; + + // Test if the actual DNS-Record differs from the host's IP. + if (ip_host == ip_dns_recheck ) { - // Next in BOOST_FOREACH + Log->print_no_update_needed(hostname, ip_dns_recheck, ip_last_update, ip_host, lastupdated); + continue; } - // Test if the actual DNS-Record differs from the host's IP. - else if ( ip_host != ip_dns_recheck ) + + // Check if the service will be updated for the first time. + if ( lastupdated == 0 ) + { + // Update for the firt time. + Log->print_update_service_firttime(hostname, ip_dns_recheck, ip_host); + service->update(ip_host,current_time); + } + else { - // Check if the service will be updated for the first time. - if ( lastupdated == 0 ) + // We already have updated, check if the IP set in last update differs from the actual host's ip. + if ( ip_last_update != ip_host ) { - // Update for the firt time. - Log->print_update_service_firttime(hostname, ip_dns_recheck, ip_host); + // Update + Log->print_update_service(hostname, ip_dns_recheck, ip_last_update, ip_host, lastupdated); service->update(ip_host,current_time); } else { - // We already have updated, check if the IP set in last update differs from the actual host's ip. - if ( ip_last_update != ip_host ) + int dns_cache_ttl = service->get_dns_cache_ttl(); + // Check if DNS Cache TTL is expired, if so, then update the same IP again. + if ( (lastupdated + dns_cache_ttl) < current_time ) { // Update - Log->print_update_service(hostname, ip_dns_recheck, ip_last_update, ip_host, lastupdated); + Log->print_update_service_ttl_expired(hostname, ip_dns_recheck, ip_last_update, ip_host, lastupdated, dns_cache_ttl, current_time); service->update(ip_host,current_time); } else { - int dns_cache_ttl = service->get_dns_cache_ttl(); - // Check if DNS Cache TTL is expired, if so, then update the same IP again. - if ( (lastupdated + dns_cache_ttl) < current_time ) - { - // Update - Log->print_update_service_ttl_expired(hostname, ip_dns_recheck, ip_last_update, ip_host, lastupdated, dns_cache_ttl, current_time); - service->update(ip_host,current_time); - } - else - { - // DNS cache TTL isn't expired - Log->print_update_service_ttl_not_expired(hostname, ip_dns_recheck, ip_last_update, ip_host, lastupdated, dns_cache_ttl, current_time); - } + // DNS cache TTL isn't expired + Log->print_update_service_ttl_not_expired(hostname, ip_dns_recheck, ip_last_update, ip_host, lastupdated, dns_cache_ttl, current_time); } } } - else - { - Log->print_no_update_needed(hostname, ip_dns_recheck, ip_last_update, ip_host, lastupdated); - } } } -- 1.7.1