Throttle the rate of UDP_INFO messages.

This makes sure UDP_INFO messages are only sent at the maximum rate of
5 per second (by default). As usual with these "probe" mechanisms, the
rate of these messages cannot be higher than the rate of data packets
themselves, since they are sent from the RX path.
This commit is contained in:
Etienne Dechamps 2015-03-08 19:54:44 +00:00
parent b1421b9190
commit 467397f25d
8 changed files with 27 additions and 3 deletions

View file

@ -31,6 +31,7 @@
#include "xalloc.h"
int maxoutbufsize = 0;
int udp_info_interval = 5;
/* Status and error notification routines */
@ -167,8 +168,15 @@ bool send_udp_info(node_t *from, node_t *to) {
if(!to->status.reachable)
return true;
if(from == myself && to->connection)
return true;
if(from == myself) {
if(to->connection)
return true;
struct timeval elapsed;
timersub(&now, &to->udp_info_sent, &elapsed);
if(elapsed.tv_sec < udp_info_interval)
return true;
}
if((myself->options | from->options | to->options) & OPTION_TCPONLY)
return true;
@ -188,6 +196,9 @@ bool send_udp_info(node_t *from, node_t *to) {
free(from_address);
free(from_port);
if(from == myself)
to->udp_info_sent = now;
return x;
}