#include "utils.h" /* for cp */
#include "xalloc.h"
-int pinginterval = 0; /* seconds between pings */
-int pingtimeout = 0; /* seconds to wait for response */
-
static int config_compare(const config_t *a, const config_t *b) {
int result;
int line;
} config_t;
-extern int pinginterval;
-extern int pingtimeout;
-extern int maxtimeout;
extern void init_configuration(struct splay_tree_t **);
extern void exit_configuration(struct splay_tree_t **);
struct ecdsa *invitation_key;
debug_t debug_level;
+ int pinginterval; /* seconds between pings */
+ int pingtimeout; /* seconds to wait for response */
+ int maxtimeout;
};
/// A handle for a MeshLink node.
*/
static void timeout_handler(void *data) {
for list_each(connection_t, c, mesh->connections) {
- if(c->last_ping_time + pingtimeout <= now.tv_sec) {
+ if(c->last_ping_time + mesh->pingtimeout <= now.tv_sec) {
if(c->status.active) {
if(c->status.pinged) {
logger(DEBUG_CONNECTIONS, LOG_INFO, "%s (%s) didn't respond to PING in %ld seconds", c->name, c->hostname, (long)now.tv_sec - c->last_ping_time);
- } else if(c->last_ping_time + pinginterval <= now.tv_sec) {
+ } else if(c->last_ping_time + mesh->pinginterval <= now.tv_sec) {
send_ping(c);
continue;
} else {
}
}
- timeout_set(data, &(struct timeval){pingtimeout, rand() % 100000});
+ timeout_set(data, &(struct timeval){mesh->pingtimeout, rand() % 100000});
}
static void periodic_handler(void *data) {
this is where it all happens...
*/
int main_loop(void) {
- timeout_add(&mesh->pingtimer, timeout_handler, &mesh->pingtimer, &(struct timeval){pingtimeout, rand() % 100000});
- timeout_add(&mesh->periodictimer, periodic_handler, &mesh->periodictimer, &(struct timeval){pingtimeout, rand() % 100000});
+ timeout_add(&mesh->pingtimer, timeout_handler, &mesh->pingtimer, &(struct timeval){mesh->pingtimeout, rand() % 100000});
+ timeout_add(&mesh->periodictimer, periodic_handler, &mesh->periodictimer, &(struct timeval){mesh->pingtimeout, rand() % 100000});
if(!event_loop()) {
logger(DEBUG_ALWAYS, LOG_ERR, "Error while waiting for input: %s", strerror(errno));
if(n->mtuprobes > 32) {
if(!n->minmtu) {
n->mtuprobes = 31;
- timeout = pinginterval;
+ timeout = mesh->pinginterval;
goto end;
}
}
if(n->mtuprobes == 31) {
- timeout = pinginterval;
+ timeout = mesh->pinginterval;
goto end;
} else if(n->mtuprobes == 32) {
- timeout = pingtimeout;
+ timeout = mesh->pingtimeout;
}
for(int i = 0; i < 4 + mesh->localdiscovery; i++) {
bool setup_myself_reloadable(void) {
mesh->localdiscovery = true;
keylifetime = 3600; // TODO: check if this can be removed as well
- maxtimeout = 900;
+ mesh->maxtimeout = 900;
autoconnect = 3;
mesh->self->options |= OPTION_PMTU_DISCOVERY;
init_edges();
init_requests();
- pinginterval = 60;
- pingtimeout = 5;
+ mesh->pinginterval = 60;
+ mesh->pingtimeout = 5;
maxoutbufsize = 10 * MTU;
if(!setup_myself())
#endif
int addressfamily = AF_UNSPEC;
-int maxtimeout = 900;
int seconds_till_retry = 5;
int max_connection_burst = 100;
void retry_outgoing(outgoing_t *outgoing) {
outgoing->timeout += 5;
- if(outgoing->timeout > maxtimeout)
- outgoing->timeout = maxtimeout;
+ if(outgoing->timeout > mesh->maxtimeout)
+ outgoing->timeout = mesh->maxtimeout;
timeout_add(&outgoing->ev, retry_outgoing_handler, outgoing, &(struct timeval){outgoing->timeout, rand() % 100000});
int left = 0, deleted = 0;
for splay_each(past_request_t, p, past_request_tree) {
- if(p->firstseen + pinginterval <= now.tv_sec)
+ if(p->firstseen + mesh->pinginterval <= now.tv_sec)
splay_delete_node(past_request_tree, node), deleted++;
else
left++;