]> git.mxchange.org Git - simgear.git/commitdiff
Improve upate interval after failed updates.
authorThorstenB <brehmt@gmail.com>
Thu, 23 Jun 2011 15:14:36 +0000 (17:14 +0200)
committerThorstenB <brehmt@gmail.com>
Thu, 23 Jun 2011 15:20:06 +0000 (17:20 +0200)
simgear/scene/tsync/terrasync.cxx

index 9f8ea8ef72a08cc1bd1f600948d4cdc2a6685434..f3b7baa20522942d76f064f3ffd9eae1ba7dd48f 100644 (file)
@@ -93,6 +93,14 @@ const char* rsync_cmd =
 const char* svn_options =
         "checkout -q";
 
+namespace UpdateInterval
+{
+    // interval in seconds to allow an update to repeat after a successful update (=daily)
+    static const double SuccessfulAttempt = 24*60*60;
+    // interval in seconds to allow another update after a failed attempt (10 minutes)
+    static const double FailedAttempt     = 10*60;
+};
+
 typedef map<string,time_t> CompletedTiles;
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -482,7 +490,7 @@ void SGTerraSync::SvnThread::run()
             _completedTiles.find( next._dir );
         time_t now = time(0);
         if ((ii == _completedTiles.end())||
-            ((ii->second + 60*60*24) < now ))
+            (ii->second < now ))
         {
             bool isNewDirectory = false;
 
@@ -491,6 +499,7 @@ void SGTerraSync::SvnThread::run()
             {
                 _consecutive_errors++;
                 _fail_count++;
+                _completedTiles[ next._dir ] = now + UpdateInterval::FailedAttempt;
             }
             else
             {
@@ -510,9 +519,9 @@ void SGTerraSync::SvnThread::run()
                         _is_dirty = true;
                     }
                 }
+                _completedTiles[ next._dir ] = now + UpdateInterval::SuccessfulAttempt;
             }
             _busy = false;
-            _completedTiles[ next._dir ] = now;
         }
 
         if (_consecutive_errors >= 5)