FACT++  1.0
static void release_conn ( int  conn_id)
static

Definition at line 1077 of file dns.c.

References node::client_prev, node::conn_id, serv::conn_id, Curr_n_servers, Curr_n_services, Debug, dim_print_date_time(), dll_empty(), dll_get_next(), dll_remove(), dna_close(), Dns_conns, do_update_did(), dtq_rem_entry(), Memory::free(), DNS_CONNECTION::n_services, Net_conns, node::next, serv::next, serv::node_head, red_serv::node_head, DNS_CONNECTION::node_head, serv::server_prev, DNS_CONNECTION::service_head, service_remove(), node::servp, SRC_DIC, SRC_DIS, SRC_NONE, DNS_CONNECTION::src_type, serv::state, Timer_q, and DNS_CONNECTION::timr_ent.

Referenced by check_validity(), handle_client_request(), handle_registration(), inform_clients(), kill_servers(), and recv_rout().

1078 {
1079  DNS_SERVICE *servp, *old_servp;
1080  NODE *nodep, *old_nodep;
1081  void service_remove();
1082 
1083  servp = (DNS_SERVICE *)Dns_conns[conn_id].service_head;
1084  nodep = (NODE *)Dns_conns[conn_id].node_head;
1085  if(( Dns_conns[conn_id].src_type == SRC_DIS ) || (servp))
1086  {
1087  if( Debug )
1088  {
1090  printf( " Conn %3d : Server %s@%s died\n",
1091  conn_id, Dns_conns[conn_id].task_name,
1092  Dns_conns[conn_id].node_name);
1093  fflush(stdout);
1094  }
1095  else
1096  {
1097  if(Dns_conns[conn_id].n_services == -1)
1098  {
1100  printf( " Conn %3d : Server %s@%s died\n",
1101  conn_id, Dns_conns[conn_id].task_name,
1102  Dns_conns[conn_id].node_name);
1103  fflush(stdout);
1104  }
1105  }
1106  Curr_n_servers--;
1107  if( Dns_conns[conn_id].timr_ent )
1108  {
1109  dtq_rem_entry( Timer_q, Dns_conns[conn_id].timr_ent );
1110  Dns_conns[conn_id].timr_ent = NULL;
1111  }
1112  servp = (DNS_SERVICE *)Dns_conns[conn_id].service_head;
1113  while( (servp = (DNS_SERVICE *) dll_get_next(
1114  (DLL *) Dns_conns[conn_id].service_head,
1115  (DLL *) servp)) )
1116  {
1117  dll_remove((DLL *) servp);
1118  if(dll_empty((DLL *) servp->node_head))
1119  {
1120  service_remove(&(servp->next));
1121  Curr_n_services--;
1122  old_servp = servp;
1123  servp = servp->server_prev;
1124  free(old_servp);
1125  }
1126  else
1127  {
1128  servp->state = 0;
1129  servp->conn_id = 0;
1130  servp = servp->server_prev;
1131  }
1132  }
1133  if(Dns_conns[conn_id].n_services)
1134  {
1135  Dns_conns[conn_id].n_services = 0;
1136 
1137  do_update_did(conn_id);
1138 /*
1139  Last_conn_id = conn_id;
1140  dis_update_service(Server_new_info_id);
1141  dis_update_service(Server_info_id);
1142 */
1143  }
1144  free((DNS_SERVICE *)Dns_conns[conn_id].service_head);
1145  Dns_conns[conn_id].service_head = 0;
1146  Dns_conns[conn_id].src_type = SRC_NONE;
1147  dna_close(conn_id);
1148  }
1149  else if((Dns_conns[conn_id].src_type == SRC_DIC) || (nodep))
1150  {
1151  if(Debug)
1152  {
1154  printf(" Conn %3d : Client %s@%s died\n",
1155  conn_id, Net_conns[conn_id].task, Net_conns[conn_id].node);
1156  fflush(stdout);
1157  }
1158  if( (nodep = (NODE *)Dns_conns[conn_id].node_head) )
1159  {
1160  while( (nodep = (NODE *) dll_get_next(
1161  (DLL *) Dns_conns[conn_id].node_head,
1162  (DLL *) nodep)) )
1163  {
1164  servp = nodep->servp;
1165  dll_remove( (DLL *) nodep );
1166  dll_remove( (DLL *) &(nodep->next) );
1167  old_nodep = nodep;
1168  nodep = nodep->client_prev;
1169  free(old_nodep);
1170  if( (dll_empty((DLL *) servp->node_head)) &&
1171  (!servp->conn_id) )
1172  {
1173  service_remove(&(servp->next));
1174  Curr_n_services--;
1175  free( servp );
1176  }
1177  }
1178  free(Dns_conns[conn_id].node_head);
1179  Dns_conns[conn_id].node_head = 0;
1180  }
1181  Dns_conns[conn_id].src_type = SRC_NONE;
1182  dna_close(conn_id);
1183  }
1184  else
1185  {
1186  if(Debug)
1187  {
1189  printf(" Conn %3d : Undefined Type %s@%s died\n",
1190  conn_id, Net_conns[conn_id].task,
1191  Net_conns[conn_id].node);
1192  fflush(stdout);
1193  }
1194  dna_close(conn_id);
1195  }
1196 }
Definition: dns.c:26
TIMR_ENT * timr_ent
Definition: dim.h:442
DllExp DIM_NOSHARE DNS_CONNECTION * Dns_conns
Definition: conn_handler.c:29
DllExp DIM_NOSHARE NET_CONNECTION * Net_conns
Definition: conn_handler.c:32
struct serv * servp
Definition: dns.c:33
char * service_head
Definition: dim.h:436
int dna_close(int conn_id)
Definition: dna.c:835
void do_update_did(int conn_id)
Definition: dns.c:587
void dll_remove(DLL *item)
Definition: dll.c:100
int conn_id
Definition: dns.c:52
static int Curr_n_servers
Definition: dns.c:73
void service_remove(RED_DNS_SERVICE *servp)
Definition: dns.c:1641
RED_NODE * node_head
Definition: dns.c:55
struct node * client_prev
Definition: dns.c:28
Definition: dim.h:530
Definition: dis.c:69
int dtq_rem_entry(int queue_id, TIMR_ENT *entry)
Definition: dtq.c:503
int state
Definition: dns.c:51
struct serv * next
Definition: dis.c:70
struct serv * server_prev
Definition: dns.c:46
int n_services
Definition: dim.h:440
int dll_empty(DLL *head)
Definition: dll.c:88
static int Timer_q
Definition: dns.c:80
void free(void *mem)
struct node * next
Definition: dns.c:29
DLL * dll_get_next(DLL *head, DLL *item)
Definition: dll.c:66
void dim_print_date_time()
Definition: utilities.c:134
static int Debug
Definition: dns.c:78
SRC_TYPES src_type
Definition: dim.h:430
char * node_head
Definition: dim.h:437
static int Curr_n_services
Definition: dns.c:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function: