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. */
splay_node_t *node, *next;
char *fname;
struct stat s;
- static time_t last_config_check = 0;
/* Reread our own configuration file */
read_config_options(config_tree, NULL);
- xasprintf(&fname, "%s/hosts/%s", confbase, myself->name);
+ xasprintf(&fname, "%s" SLASH "hosts" SLASH "%s", confbase, myself->name);
read_config_file(config_tree, fname);
free(fname);
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/hosts/%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) {
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);
if(!subnet->expires)
subnet->expires = 1;
}
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);
if(s2->expires == 1)
s2->expires = 0;
free_subnet(subnet);
} else {
- logger(DEBUG_ALWAYS, LOG_DEBUG, "read new subnet %p", subnet);
subnet_add(myself, subnet);
send_add_subnet(everyone, subnet);
subnet_update(myself, subnet, true);
next = node->next;
subnet_t *subnet = node->data;
if(subnet->expires == 1) {
- logger(DEBUG_ALWAYS, LOG_DEBUG, "removed subnet %p", subnet);
send_del_subnet(everyone, subnet);
subnet_update(myself, subnet, false);
subnet_del(myself, subnet);
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;
}