Commit ad9b1542 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Expire sources periodically.

We only expire sources every 5 minutes, since it's a somewhat costly
operation.
parent 5c615095
......@@ -99,7 +99,7 @@ main(int argc, char **argv)
struct sockaddr_in6 sin6;
int i, rc, fd, rfd, have_id = 0;
struct timeval check_neighbours_time;
time_t expiry_time, kernel_dump_time;
time_t expiry_time, source_expiry_time, kernel_dump_time;
char *config_file = NULL;
void *vrc;
unsigned int seed;
......@@ -510,6 +510,7 @@ main(int argc, char **argv)
kernel_dump_time = now.tv_sec + 20 + random() % 20;
timeval_plus_msec(&check_neighbours_time, &now, 5000 + random() % 5000);
expiry_time = now.tv_sec + 20 + random() % 20;
source_expiry_time = now.tv_sec + 200 + random() % 200;
/* Make some noise so that others notice us */
for(i = 0; i < numnets; i++) {
......@@ -536,6 +537,7 @@ main(int argc, char **argv)
tv = check_neighbours_time;
timeval_min_sec(&tv, expiry_time);
timeval_min_sec(&tv, source_expiry_time);
timeval_min_sec(&tv, kernel_dump_time);
timeval_min(&tv, &request_resend_time);
for(i = 0; i < numnets; i++) {
......@@ -646,6 +648,11 @@ main(int argc, char **argv)
expiry_time = now.tv_sec + 20 + random() % 20;
}
if(now.tv_sec >= source_expiry_time) {
expire_sources();
source_expiry_time = now.tv_sec + 200 + random() % 200;
}
for(i = 0; i < numnets; i++) {
if(!nets[i].up)
continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment