Add DNS TTL/server error threshold so we don't update with the same IP too often
authorThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 20 Oct 2010 12:14:26 +0000 (14:14 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Wed, 20 Oct 2010 12:14:26 +0000 (14:14 +0200)
src/updater.cpp

index 84247d5..f204b4f 100644 (file)
 using namespace std;
 
 
+/// Server error threshold: When the host IP is not current, the DNS TTL expired
+/// and we already sent an update.
+const int ServerErrorTTLExpiredThreshold = 15 * 60;
+
+
 /**
  * Default constructor which initializes the member Conf.
  */
@@ -276,6 +281,12 @@ void Updater::update_services(bool changed_to_online) const
         else
         {
             int dns_cache_ttl = service->get_dns_cache_ttl();
+
+            // Add server error threshold so we don't jam the server with updates for the same IP
+            // in case the server doesn't hand out the already sent IP via DNS
+            // (might indicate a server error).
+            dns_cache_ttl += ServerErrorTTLExpiredThreshold;
+
             // Check if DNS Cache TTL is expired, if so, then update the same IP again.
             if ( (lastupdated + dns_cache_ttl) < current_time )
             {