- /* First check if the host is already in our
- connection list. If so, we are probably making a loop, which
- is not desirable.
- */
-
- if((old = lookup_id(cl->name)))
- {
- if(debug_lvl >= DEBUG_CONNECTIONS)
- syslog(LOG_NOTICE, _("%s (%s) is already in our connection list"), cl->name, cl->hostname);
- if(cl->status.outgoing)
- {
- cl->status.outgoing = 0;
- old->status.outgoing = 1;
- }
- terminate_connection(cl);
- return 0;
- }
-
- /* Now we can add the name to the id tree */
-
- id_add(cl);
-
- /* And uhr... cl->port just changed so we have to unlink it from the connection tree and re-insert... */
-
- node = avl_unlink(connection_tree, cl);
- cl->port = port;
- if(!avl_insert_node(connection_tree, node))
- {
- old = avl_search_node(connection_tree, node)->data;
- syslog(LOG_ERR, _("%s is listening on %s:%hd, which is already in use by %s!"),
- cl->name, cl->hostname, cl->port, old->name);
- return -1;
- }
-