Commit aca69890 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Add urgent argument to jitter.

parent 17ef2b95
......@@ -373,7 +373,7 @@ flushbuf(struct network *net)
static void
schedule_flush(struct network *net)
{
int msecs = jitter(net);
int msecs = jitter(net, 0);
if(net->flush_timeout.tv_sec != 0 &&
timeval_minus_msec(&net->flush_timeout, &now) < msecs)
return;
......
......@@ -108,10 +108,13 @@ update_hello_interval(struct network *net)
/* This should be no more than half the hello interval, so that hellos
aren't sent late. The result is in milliseconds. */
unsigned int
jitter(struct network *net)
jitter(struct network *net, int urgent)
{
unsigned interval = net->hello_interval;
interval = MIN(interval, 2000);
if(urgent)
interval = MIN(interval, 100);
else
interval = MIN(interval, 2000);
return (interval / 2 + random() % interval) / 4;
}
......
......@@ -54,7 +54,7 @@ extern int numnets;
struct network *add_network(char *ifname);
int network_idle(struct network *net);
int update_hello_interval(struct network *net);
unsigned int jitter(struct network *net);
unsigned int jitter(struct network *net, int urgent);
unsigned int update_jitter(struct network *net, int urgent);
void delay_jitter(struct timeval *time, struct timeval *timeout, int msecs);
int network_up(struct network *net, int up);
......
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