Commit 15940ce0 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Compute a smaller jitter when sending urgent updates.

parent 2391e74a
...@@ -785,9 +785,10 @@ jitter(struct network *net) ...@@ -785,9 +785,10 @@ jitter(struct network *net)
} }
unsigned int unsigned int
update_jitter(struct network *net) update_jitter(struct network *net, int urgent)
{ {
unsigned interval = net->hello_interval * 1000; unsigned interval = net->hello_interval * 1000;
if(urgent)
interval = MIN(interval, 1000);
return (interval / 2 + random() % interval); return (interval / 2 + random() % interval);
} }
...@@ -102,5 +102,5 @@ extern int max_request_hopcount; ...@@ -102,5 +102,5 @@ extern int max_request_hopcount;
int network_idle(struct network *net); int network_idle(struct network *net);
int update_hello_interval(struct network *net); int update_hello_interval(struct network *net);
unsigned int jitter(struct network *net); unsigned int jitter(struct network *net);
unsigned int update_jitter(struct network *net); unsigned int update_jitter(struct network *net, int urgent);
...@@ -520,10 +520,10 @@ flushupdates(void) ...@@ -520,10 +520,10 @@ flushupdates(void)
} }
static void static void
schedule_update_flush(struct network *net) schedule_update_flush(struct network *net, int urgent)
{ {
int msecs; int msecs;
msecs = update_jitter(net); msecs = update_jitter(net, urgent);
if(update_flush_time.tv_sec != 0 && if(update_flush_time.tv_sec != 0 &&
timeval_minus_msec(&update_flush_time, &now) < msecs) timeval_minus_msec(&update_flush_time, &now) < msecs)
return; return;
...@@ -598,7 +598,7 @@ send_update(struct network *net, int urgent, ...@@ -598,7 +598,7 @@ send_update(struct network *net, int urgent,
buffer_update(net, routes[i].src->prefix, routes[i].src->plen); buffer_update(net, routes[i].src->prefix, routes[i].src->plen);
net->update_time = now.tv_sec; net->update_time = now.tv_sec;
} }
schedule_update_flush(net); schedule_update_flush(net, urgent);
} }
void void
......
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