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) ...@@ -99,7 +99,7 @@ main(int argc, char **argv)
struct sockaddr_in6 sin6; struct sockaddr_in6 sin6;
int i, rc, fd, rfd, have_id = 0; int i, rc, fd, rfd, have_id = 0;
struct timeval check_neighbours_time; 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; char *config_file = NULL;
void *vrc; void *vrc;
unsigned int seed; unsigned int seed;
...@@ -510,6 +510,7 @@ main(int argc, char **argv) ...@@ -510,6 +510,7 @@ main(int argc, char **argv)
kernel_dump_time = now.tv_sec + 20 + random() % 20; kernel_dump_time = now.tv_sec + 20 + random() % 20;
timeval_plus_msec(&check_neighbours_time, &now, 5000 + random() % 5000); timeval_plus_msec(&check_neighbours_time, &now, 5000 + random() % 5000);
expiry_time = now.tv_sec + 20 + random() % 20; 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 */ /* Make some noise so that others notice us */
for(i = 0; i < numnets; i++) { for(i = 0; i < numnets; i++) {
...@@ -536,6 +537,7 @@ main(int argc, char **argv) ...@@ -536,6 +537,7 @@ main(int argc, char **argv)
tv = check_neighbours_time; tv = check_neighbours_time;
timeval_min_sec(&tv, expiry_time); timeval_min_sec(&tv, expiry_time);
timeval_min_sec(&tv, source_expiry_time);
timeval_min_sec(&tv, kernel_dump_time); timeval_min_sec(&tv, kernel_dump_time);
timeval_min(&tv, &request_resend_time); timeval_min(&tv, &request_resend_time);
for(i = 0; i < numnets; i++) { for(i = 0; i < numnets; i++) {
...@@ -646,6 +648,11 @@ main(int argc, char **argv) ...@@ -646,6 +648,11 @@ main(int argc, char **argv)
expiry_time = now.tv_sec + 20 + random() % 20; 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++) { for(i = 0; i < numnets; i++) {
if(!nets[i].up) if(!nets[i].up)
continue; 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