X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fnet.c;h=8cf4a765673b755a5d87dfd0a79ab272e63a4718;hb=c5325ffdd1c6749beaf842c272eb28ecd5a070b6;hp=1a450413a11d7907310591a5db34dea0826e7a38;hpb=18237e1f2d9dd5eef4a4e0d746d016bf94a42ad4;p=tinc diff --git a/src/net.c b/src/net.c index 1a450413..8cf4a765 100644 --- a/src/net.c +++ b/src/net.c @@ -40,6 +40,7 @@ int contradicting_add_edge = 0; int contradicting_del_edge = 0; static int sleeptime = 10; +time_t last_config_check = 0; /* Purge edges and subnets of unreachable nodes. Use carefully. */ @@ -263,7 +264,6 @@ int reload_configuration(void) { splay_node_t *node, *next; char *fname; struct stat s; - static time_t last_config_check = 0; /* Reread our own configuration file */ @@ -286,31 +286,6 @@ int reload_configuration(void) { setup_myself_reloadable(); - /* Close connections to hosts that have a changed or deleted host config file */ - - for(node = connection_tree->head; node; node = next) { - c = node->data; - next = node->next; - - if(c->status.control) - continue; - - if(c->outgoing) { - free(c->outgoing->name); - if(c->outgoing->ai) - freeaddrinfo(c->outgoing->ai); - free(c->outgoing); - c->outgoing = NULL; - } - - xasprintf(&fname, "%s" SLASH "hosts" SLASH "%s", confbase, c->name); - if(stat(fname, &s) || s.st_mtime > last_config_check) - terminate_connection(c, c->status.active); - free(fname); - } - - last_config_check = time(NULL); - /* If StrictSubnet is set, expire deleted Subnets and read new ones in */ if(strictsubnets) { @@ -344,7 +319,7 @@ int reload_configuration(void) { for(node = myself->subnet_tree->head; node; node = node->next) { subnet_t *subnet = node->data; - logger(DEBUG_ALWAYS, LOG_DEBUG, "subnet %p expires %d\n", subnet, (int)subnet->expires); + logger(DEBUG_ALWAYS, LOG_DEBUG, "subnet %p expires %d", subnet, (int)subnet->expires); if(!subnet->expires) subnet->expires = 1; } @@ -356,7 +331,7 @@ int reload_configuration(void) { continue; if((s2 = lookup_subnet(myself, subnet))) { - logger(DEBUG_ALWAYS, LOG_DEBUG, "read subnet that already exists: %p expires %d\n", s2, (int)s2->expires); + logger(DEBUG_ALWAYS, LOG_DEBUG, "read subnet that already exists: %p expires %d", s2, (int)s2->expires); if(s2->expires == 1) s2->expires = 0; @@ -387,6 +362,25 @@ int reload_configuration(void) { try_outgoing_connections(); + /* Close connections to hosts that have a changed or deleted host config file */ + + for(node = connection_tree->head; node; node = next) { + c = node->data; + next = node->next; + + if(c->status.control) + continue; + + xasprintf(&fname, "%s" SLASH "hosts" SLASH "%s", confbase, c->name); + if(stat(fname, &s) || s.st_mtime > last_config_check) { + fprintf(stderr, "ZOMG %ld > %ld\n", s.st_mtime, last_config_check); + terminate_connection(c, c->status.active); + } + free(fname); + } + + last_config_check = time(NULL); + return 0; }