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