-/*
- accept a new tcp connect and create a
- new connection
-*/
-int handle_new_meta_connection(conn_list_t *cl)
-{
- conn_list_t *ncn;
- struct sockaddr client;
- int nfd, len = sizeof(client);
-cp
- if((nfd = accept(cl->meta_socket, &client, &len)) < 0)
- {
- syslog(LOG_ERR, "Accepting a new connection failed: %m");
- return -1;
- }
-
- if((ncn = create_new_connection(nfd)) == NULL)
- {
- shutdown(nfd, 2);
- close(nfd);
- syslog(LOG_NOTICE, "Closed attempted connection.");
- return 0;
- }
-
- ncn->status.meta = 1;
- ncn->next = conn_list;
- conn_list = ncn;
-cp
- return 0;
-}
+ last_config_check = time(NULL);
+
+ /* If StrictSubnet is set, expire deleted Subnets and read new ones in */
+
+ if(strictsubnets) {
+ subnet_t *subnet;
+
+ for(node = subnet_tree->head; node; node = node->next) {
+ subnet = node->data;
+ subnet->expires = 1;
+ }
+
+ load_all_subnets();
+
+ for(node = subnet_tree->head; node; node = next) {
+ next = node->next;
+ subnet = node->data;
+ 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 */
+ subnet_t *subnet, *s2;
+
+ 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;
+ }
+
+ config_t *cfg = lookup_config(config_tree, "Subnet");
+
+ while(cfg) {
+ if(!get_config_subnet(cfg, &subnet))
+ 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);
+ }
+
+ cfg = lookup_config_next(config_tree, cfg);
+ }
+
+ for(node = myself->subnet_tree->head; node; node = next) {
+ 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);
+ }
+ }
+ }