diff src/routeflapper.cpp @ 2:bb3f804f13a0

add random unsynchronization to hourly timer, trust prefix only for same origin AS, ignore self adjacency
author Carl Byington <carl@five-ten-sg.com>
date Mon, 19 May 2008 21:45:45 -0700
parents 48d06780cf77
children 4a81cc2da570
line wrap: on
line diff
--- a/src/routeflapper.cpp	Tue May 13 15:46:53 2008 -0700
+++ b/src/routeflapper.cpp	Mon May 19 21:45:45 2008 -0700
@@ -91,17 +91,22 @@
 //
 void* hourly_update(void *arg);
 void* hourly_update(void *arg) {
+    while (loader_run) {
+        int ran    = (rand() % 600) - 300;  // random(-5min,+5min)
+        int hour   = 3600 - 60 + ran;       // 59 minutes +- random up to 5 minutes.
+        int period = (hour + 10) / 20;      // twenty periods ...
     int count = 0;
     while (loader_run) {
-        sleep(180);
-        if (!loader_run) break;
+            sleep(period);
+            if (!loader_run) break;         // ... so we only wait about 3 minutes to terminate
         count++;
         if (count == 20) {
-            routing_hourly_update();
+                routing_hourly_update();    // roughly an hour
             count = 0;
         };
     }
 }
+}
 
 
 ////////////////////////////////////////////////