-/*
- terminate a connection and notify the other
- end before closing the sockets
-*/
-void terminate_connection(conn_list_t *cl)
-{
-cp
- if(cl->status.remove)
- return;
-
- if(debug_lvl > 0)
- syslog(LOG_NOTICE, "Closing connection with %s.", cl->hostname);
-
- if(cl->status.timeout)
- send_timeout(cl);
- else if(!cl->status.termreq)
- send_termreq(cl);
-
- close(cl->socket);
- if(cl->status.meta)
- close(cl->meta_socket);
-
- if(cl->status.outgoing)
- {
- signal(SIGALRM, sigalrm_handler);
- seconds_till_retry = 5;
- alarm(seconds_till_retry);
- syslog(LOG_NOTICE, "Try to re-establish outgoing connection in 5 seconds.");
- }
-
- cl->status.active = 0;
- cl->status.remove = 1;
-cp
-}
+ load_all_nodes();
+
+ if(strictsubnets) {
+ for splay_each(subnet_t, subnet, subnet_tree) {
+ if(!subnet->owner) {
+ continue;
+ }
+
+ if(subnet->expires == 1) {
+ send_del_subnet(everyone, subnet);
+
+ if(subnet->owner->status.reachable) {
+ subnet_update(subnet->owner, subnet, false);
+ }
+
+ subnet_del(subnet->owner, subnet);
+ } else if(subnet->expires == -1) {
+ subnet->expires = 0;
+ } else {
+ send_add_subnet(everyone, subnet);
+
+ if(subnet->owner->status.reachable) {
+ subnet_update(subnet->owner, subnet, true);
+ }
+ }
+ }
+ } else { /* Only read our own subnets back in */
+ for splay_each(subnet_t, subnet, myself->subnet_tree)
+ if(!subnet->expires) {
+ subnet->expires = 1;
+ }
+
+ config_t *cfg = lookup_config(config_tree, "Subnet");
+
+ while(cfg) {
+ subnet_t *subnet, *s2;
+
+ if(!get_config_subnet(cfg, &subnet)) {
+ continue;
+ }
+
+ if((s2 = lookup_subnet(myself, subnet))) {
+ if(s2->expires == 1) {
+ s2->expires = 0;
+ }
+
+ free_subnet(subnet);
+ } else {
+ subnet_add(myself, subnet);
+ send_add_subnet(everyone, subnet);
+ subnet_update(myself, subnet, true);
+ }
+
+ cfg = lookup_config_next(config_tree, cfg);
+ }
+
+ for splay_each(subnet_t, subnet, myself->subnet_tree) {
+ if(subnet->expires == 1) {
+ send_del_subnet(everyone, subnet);
+ subnet_update(myself, subnet, false);
+ subnet_del(myself, subnet);
+ }
+ }
+ }