#include "conf_net.h"
#include "conf.h"
#include "connection.h"
+#include "crypto.h"
#include "graph.h"
#include "logger.h"
#include "meta.h"
#include "protocol.h"
#include "subnet.h"
#include "utils.h"
+#include "watchdog.h"
int contradicting_add_edge = 0;
int contradicting_del_edge = 0;
if(!n->status.reachable) {
logger(DEBUG_SCARY_THINGS, LOG_DEBUG, "Purging node %s (%s)", n->name, n->hostname);
- for splay_each(subnet_t, s, n->subnet_tree) {
+ for splay_each(subnet_t, s, &n->subnet_tree) {
send_del_subnet(everyone, s);
if(!strictsubnets) {
}
}
- for splay_each(edge_t, e, n->edge_tree) {
+ for splay_each(edge_t, e, &n->edge_tree) {
if(!tunnelserver) {
send_del_edge(everyone, e);
}
return;
}
- if(!autoconnect && (!strictsubnets || !n->subnet_tree->head))
+ if(!autoconnect && (!strictsubnets || !n->subnet_tree.head))
/* in strictsubnets mode do not delete nodes with subnets */
{
node_del(n);
do_outgoing_connection(outgoing);
}
-#ifndef HAVE_MINGW
+#ifndef HAVE_WINDOWS
/* Clean up dead proxy processes */
while(waitpid(-1, NULL, WNOHANG) > 0);
by default
*/
if(sleep_time > 2 * udp_discovery_timeout) {
+#ifdef HAVE_WATCHDOG
+ watchdog_ping();
+#endif
logger(DEBUG_ALWAYS, LOG_ERR, "Awaking from dead after %ld seconds of sleep", sleep_time);
/*
Do not send any packets to tinc after we wake up.
}
timeout_set(data, &(struct timeval) {
- 1, rand() % 100000
+ 1, jitter()
});
}
if(contradicting_del_edge > 100 && contradicting_add_edge > 100) {
logger(DEBUG_ALWAYS, LOG_WARNING, "Possible node with same Name as us! Sleeping %d seconds.", sleeptime);
- nanosleep(&(struct timespec) {
- sleeptime, 0
- }, NULL);
+ sleep_millis(sleeptime * 1000);
sleeptime *= 2;
if(sleeptime < 0) {
}
timeout_set(data, &(struct timeval) {
- 5, rand() % 100000
+ 5, jitter()
});
}
}
}
-#ifndef HAVE_MINGW
+#ifndef HAVE_WINDOWS
static void sigterm_handler(void *data) {
logger(DEBUG_ALWAYS, LOG_NOTICE, "Got %s signal", strsignal(((signal_t *)data)->signum));
event_exit();
}
}
} else { /* Only read our own subnets back in */
- for splay_each(subnet_t, subnet, myself->subnet_tree)
+ for splay_each(subnet_t, subnet, &myself->subnet_tree)
if(!subnet->expires) {
subnet->expires = 1;
}
cfg = lookup_config_next(&config_tree, cfg);
}
- for splay_each(subnet_t, subnet, myself->subnet_tree) {
+ for splay_each(subnet_t, subnet, &myself->subnet_tree) {
if(subnet->expires == 1) {
send_del_subnet(everyone, subnet);
subnet_update(myself, subnet, false);
int main_loop(void) {
last_periodic_run_time = now;
timeout_add(&pingtimer, timeout_handler, &pingtimer, &(struct timeval) {
- pingtimeout, rand() % 100000
+ pingtimeout, jitter()
});
timeout_add(&periodictimer, periodic_handler, &periodictimer, &(struct timeval) {
0, 0
});
-#ifndef HAVE_MINGW
+#ifndef HAVE_WINDOWS
signal_t sighup = {0};
signal_t sigterm = {0};
signal_t sigquit = {0};
return 1;
}
-#ifndef HAVE_MINGW
+#ifndef HAVE_WINDOWS
signal_del(&sighup);
signal_del(&sigterm);
signal_del(&sigquit);