Commit 3580913a authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Rename flush_time to flush_timeout for consistency.

parent f3ed6390
...@@ -528,14 +528,14 @@ main(int argc, char **argv) ...@@ -528,14 +528,14 @@ main(int argc, char **argv)
for(i = 0; i < numnets; i++) { for(i = 0; i < numnets; i++) {
if(!nets[i].up) if(!nets[i].up)
continue; continue;
timeval_min(&tv, &nets[i].flush_time); timeval_min(&tv, &nets[i].flush_timeout);
timeval_min(&tv, &nets[i].hello_timeout); timeval_min(&tv, &nets[i].hello_timeout);
if(!network_idle(&nets[i])) { if(!network_idle(&nets[i])) {
timeval_min(&tv, &nets[i].self_update_timeout); timeval_min(&tv, &nets[i].self_update_timeout);
timeval_min(&tv, &nets[i].update_timeout); timeval_min(&tv, &nets[i].update_timeout);
} }
} }
timeval_min(&tv, &update_flush_time); timeval_min(&tv, &update_flush_timeout);
FD_ZERO(&readfds); FD_ZERO(&readfds);
if(timeval_compare(&tv, &now) > 0) { if(timeval_compare(&tv, &now) > 0) {
timeval_minus(&tv, &tv, &now); timeval_minus(&tv, &tv, &now);
...@@ -653,16 +653,16 @@ main(int argc, char **argv) ...@@ -653,16 +653,16 @@ main(int argc, char **argv)
if(now.tv_sec >= request_resend_time) if(now.tv_sec >= request_resend_time)
resend_requests(); resend_requests();
if(update_flush_time.tv_sec != 0) { if(update_flush_timeout.tv_sec != 0) {
if(now.tv_sec >= update_flush_time.tv_sec) if(now.tv_sec >= update_flush_timeout.tv_sec)
flushupdates(); flushupdates();
} }
for(i = 0; i < numnets; i++) { for(i = 0; i < numnets; i++) {
if(!nets[i].up) if(!nets[i].up)
continue; continue;
if(nets[i].flush_time.tv_sec != 0) { if(nets[i].flush_timeout.tv_sec != 0) {
if(timeval_compare(&now, &nets[i].flush_time) >= 0) if(timeval_compare(&now, &nets[i].flush_timeout) >= 0)
flushbuf(&nets[i]); flushbuf(&nets[i]);
} }
} }
......
...@@ -39,7 +39,7 @@ THE SOFTWARE. ...@@ -39,7 +39,7 @@ THE SOFTWARE.
#include "message.h" #include "message.h"
#include "filter.h" #include "filter.h"
struct timeval update_flush_time = {0, 0}; struct timeval update_flush_timeout = {0, 0};
const unsigned char packet_header[8] = {42, 1}; const unsigned char packet_header[8] = {42, 1};
...@@ -361,19 +361,19 @@ flushbuf(struct network *net) ...@@ -361,19 +361,19 @@ flushbuf(struct network *net)
} }
VALGRIND_MAKE_MEM_UNDEFINED(net->sendbuf, net->bufsize); VALGRIND_MAKE_MEM_UNDEFINED(net->sendbuf, net->bufsize);
net->buffered = 0; net->buffered = 0;
net->flush_time.tv_sec = 0; net->flush_timeout.tv_sec = 0;
net->flush_time.tv_usec = 0; net->flush_timeout.tv_usec = 0;
} }
static void static void
schedule_flush(struct network *net) schedule_flush(struct network *net)
{ {
int msecs = jitter(net); int msecs = jitter(net);
if(net->flush_time.tv_sec != 0 && if(net->flush_timeout.tv_sec != 0 &&
timeval_minus_msec(&net->flush_time, &now) < msecs) timeval_minus_msec(&net->flush_timeout, &now) < msecs)
return; return;
net->flush_time.tv_usec = (now.tv_usec + msecs * 1000) % 1000000; net->flush_timeout.tv_usec = (now.tv_usec + msecs * 1000) % 1000000;
net->flush_time.tv_sec = now.tv_sec + (now.tv_usec / 1000 + msecs) / 1000; net->flush_timeout.tv_sec = now.tv_sec + (now.tv_usec / 1000 + msecs) / 1000;
} }
void void
...@@ -381,11 +381,12 @@ schedule_flush_now(struct network *net) ...@@ -381,11 +381,12 @@ schedule_flush_now(struct network *net)
{ {
/* Almost now */ /* Almost now */
int msecs = 5 + random() % 5; int msecs = 5 + random() % 5;
if(net->flush_time.tv_sec != 0 && if(net->flush_timeout.tv_sec != 0 &&
timeval_minus_msec(&net->flush_time, &now) < msecs) timeval_minus_msec(&net->flush_timeout, &now) < msecs)
return; return;
net->flush_time.tv_usec = (now.tv_usec + msecs * 1000) % 1000000; net->flush_timeout.tv_usec = (now.tv_usec + msecs * 1000) % 1000000;
net->flush_time.tv_sec = now.tv_sec + (now.tv_usec / 1000 + msecs) / 1000; net->flush_timeout.tv_sec =
now.tv_sec + (now.tv_usec / 1000 + msecs) / 1000;
} }
static void static void
...@@ -674,8 +675,8 @@ flushupdates(void) ...@@ -674,8 +675,8 @@ flushupdates(void)
VALGRIND_MAKE_MEM_UNDEFINED(&buffered_updates, VALGRIND_MAKE_MEM_UNDEFINED(&buffered_updates,
sizeof(buffered_updates)); sizeof(buffered_updates));
} }
update_flush_time.tv_sec = 0; update_flush_timeout.tv_sec = 0;
update_flush_time.tv_usec = 0; update_flush_timeout.tv_usec = 0;
} }
static void static void
...@@ -683,11 +684,12 @@ schedule_update_flush(struct network *net, int urgent) ...@@ -683,11 +684,12 @@ schedule_update_flush(struct network *net, int urgent)
{ {
int msecs; int msecs;
msecs = update_jitter(net, urgent); msecs = update_jitter(net, urgent);
if(update_flush_time.tv_sec != 0 && if(update_flush_timeout.tv_sec != 0 &&
timeval_minus_msec(&update_flush_time, &now) < msecs) timeval_minus_msec(&update_flush_timeout, &now) < msecs)
return; return;
update_flush_time.tv_usec = (now.tv_usec + msecs * 1000) % 1000000; update_flush_timeout.tv_usec = (now.tv_usec + msecs * 1000) % 1000000;
update_flush_time.tv_sec = now.tv_sec + (now.tv_usec / 1000 + msecs) / 1000; update_flush_timeout.tv_sec =
now.tv_sec + (now.tv_usec / 1000 + msecs) / 1000;
} }
static void static void
......
...@@ -31,7 +31,7 @@ extern int silent_time; ...@@ -31,7 +31,7 @@ extern int silent_time;
extern int broadcast_ihu; extern int broadcast_ihu;
extern int split_horizon; extern int split_horizon;
extern struct timeval update_flush_time; extern struct timeval update_flush_timeout;
extern const unsigned char packet_header[8]; extern const unsigned char packet_header[8];
unsigned short hash_id(const unsigned char *id) ATTRIBUTE ((pure)); unsigned short hash_id(const unsigned char *id) ATTRIBUTE ((pure));
......
...@@ -36,7 +36,7 @@ struct network { ...@@ -36,7 +36,7 @@ struct network {
char ifname[IF_NAMESIZE]; char ifname[IF_NAMESIZE];
unsigned char *ipv4; unsigned char *ipv4;
int buffered; int buffered;
struct timeval flush_time; struct timeval flush_timeout;
int bufsize; int bufsize;
unsigned char *sendbuf; unsigned char *sendbuf;
int bucket_time; int bucket_time;
......
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