comparison 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
comparison
equal deleted inserted replaced
1:47f787af96c1 2:bb3f804f13a0
89 //////////////////////////////////////////////// 89 ////////////////////////////////////////////////
90 // thread to update hourly statistics 90 // thread to update hourly statistics
91 // 91 //
92 void* hourly_update(void *arg); 92 void* hourly_update(void *arg);
93 void* hourly_update(void *arg) { 93 void* hourly_update(void *arg) {
94 int count = 0;
95 while (loader_run) { 94 while (loader_run) {
96 sleep(180); 95 int ran = (rand() % 600) - 300; // random(-5min,+5min)
97 if (!loader_run) break; 96 int hour = 3600 - 60 + ran; // 59 minutes +- random up to 5 minutes.
98 count++; 97 int period = (hour + 10) / 20; // twenty periods ...
99 if (count == 20) { 98 int count = 0;
100 routing_hourly_update(); 99 while (loader_run) {
101 count = 0; 100 sleep(period);
102 }; 101 if (!loader_run) break; // ... so we only wait about 3 minutes to terminate
102 count++;
103 if (count == 20) {
104 routing_hourly_update(); // roughly an hour
105 count = 0;
106 };
107 }
103 } 108 }
104 } 109 }
105 110
106 111
107 //////////////////////////////////////////////// 112 ////////////////////////////////////////////////