- connection_t *p;
- subnet_t *subnet;
- avl_node_t *node, *next;
-cp
- if(cl->status.remove)
- return;
-
- if(debug_lvl >= DEBUG_CONNECTIONS)
- syslog(LOG_NOTICE, _("Closing connection with %s (%s)"),
- cl->name, cl->hostname);
-
- cl->status.remove = 1;
-
- if(cl->socket)
- close(cl->socket);
- if(cl->status.meta)
- close(cl->meta_socket);
-
- if(cl->status.meta)
- {
-
- /* Find all connections that were lost because they were behind cl
- (the connection that was dropped). */
-
- for(node = connection_tree->head; node; node = node->next)
- {
- p = (connection_t *)node->data;
- if(p->nexthop == cl && p != cl)
- terminate_connection(p);
- }
-
- /* Inform others of termination if it was still active */
-
- if(cl->status.active)
- for(node = connection_tree->head; node; node = node->next)
- {
- p = (connection_t *)node->data;
- if(p->status.meta && p->status.active && p != cl)
- send_del_host(p, cl); /* Sounds like recursion, but p does not have a meta connection :) */
- }
- }
-
- /* Remove the associated subnets */
-
- for(node = cl->subnet_tree->head; node; node = next)
- {
- next = node->next;
- subnet = (subnet_t *)node->data;
- subnet_del(subnet);
- }
-
- /* Check if this was our outgoing connection */
-
- if(cl->status.outgoing)
- {
- cl->status.outgoing = 0;
- signal(SIGALRM, sigalrm_handler);
- seconds_till_retry = 5;
- alarm(seconds_till_retry);
- syslog(LOG_NOTICE, _("Trying to re-establish outgoing connection in 5 seconds"));
- }
-
- /* Inactivate */
-
- cl->status.active = 0;
-cp