FACT++  1.0
int dis_remove_service ( unsigned  service_id)

Definition at line 2112 of file dis.c.

References Debug_on, serv::delay_delete, DIM_ERROR, dim_print_date_time(), DIMSVCINVAL, dis_dns_ent::dis_client_id, Dis_conn_id, dis_hash_service_remove(), dis_dns_ent::dis_n_services, dis_dns_ent::dis_service_id, dll_get_next(), dna_close(), serv::dnsp, do_dis_stop_serving_dns(), error_handler(), Memory::free(), serv::id, id_free(), id_get_ptr(), serv::name, req_ent::prev, release_request(), remove_service(), req_ent::req_id, req_ent::reqpp, serv::request_head, service_id, dis_dns_ent::serving, sprintf(), SRC_DIS, str, serv::to_delete, and unregister_service().

Referenced by dis_hash_print(), dis_stop_serving(), do_dis_add_service(), do_dis_stop_serving_dns(), and do_update_service().

2113 {
2114  register REQUEST *reqp, *auxp;
2115  register SERVICE *servp;
2116  REQUEST_PTR *reqpp;
2117  int found = 0;
2118  char str[128];
2119  int release_request();
2121  DIS_DNS_CONN *dnsp;
2122  int n_services;
2124 
2125  DISABLE_AST
2126  if(!service_id)
2127  {
2128  sprintf(str,"Remove Service - Invalid service id");
2129  error_handler(0, DIM_ERROR, DIMSVCINVAL, str, -1);
2130  ENABLE_AST
2131  return(found);
2132  }
2133  servp = (SERVICE *)id_get_ptr(service_id, SRC_DIS);
2134  if(!servp)
2135  {
2136  ENABLE_AST
2137  return(found);
2138  }
2139  if(servp->id != (int)service_id)
2140  {
2141  ENABLE_AST
2142  return(found);
2143  }
2144 if(Debug_on)
2145 {
2147  printf("Removing service %s, delay_delete = %d\n",
2148  servp->name, servp->delay_delete);
2149 }
2150  if(servp->delay_delete)
2151  {
2152  servp->to_delete = 1;
2153  ENABLE_AST
2154  return(found);
2155  }
2156  /* remove from name server */
2157 
2158  dnsp = servp->dnsp;
2159  unregister_service(dnsp, servp);
2160  /* Release client requests and remove from actual clients */
2161  reqp = servp->request_head;
2162  while( (reqp = (REQUEST *) dll_get_next((DLL *)servp->request_head,
2163  (DLL *) reqp)) )
2164  {
2165  remove_service(reqp->req_id);
2166  auxp = reqp->prev;
2167  reqpp = (REQUEST_PTR *) reqp->reqpp;
2168  release_request(reqp, reqpp, 1);
2169  found = 1;
2170  reqp = auxp;
2171  }
2172  if(servp->id == (int)dnsp->dis_service_id)
2173  dnsp->dis_service_id = 0;
2174  if(servp->id == (int)dnsp->dis_client_id)
2175  dnsp->dis_client_id = 0;
2176  dis_hash_service_remove(servp);
2177  id_free(servp->id, SRC_DIS);
2178  free(servp->request_head);
2179  free(servp);
2180 /*
2181  if(dnsp != Default_DNS)
2182  {
2183  dnsp->dis_n_services--;
2184  n_services = dnsp->dis_n_services;
2185  }
2186  else
2187  {
2188  Dis_n_services--;
2189  n_services = Dis_n_services;
2190  }
2191 */
2192  dnsp->dis_n_services--;
2193  n_services = dnsp->dis_n_services;
2194 
2195  if(dnsp->serving)
2196  {
2197  if(n_services == 5)
2198  {
2199  if(Dis_conn_id)
2200  {
2202  Dis_conn_id = 0;
2203  }
2204  ENABLE_AST
2205 /*
2206  dis_stop_serving();
2207 */
2209  }
2210  else
2211  {
2212  ENABLE_AST
2213  }
2214  }
2215  else
2216  {
2217  ENABLE_AST
2218  }
2219  return(found);
2220 }
static void error_handler(int conn_id, int severity, int errcode, char *reason, int exit)
Definition: dis.c:3199
DIS_DNS_CONN * dnsp
Definition: dis.c:87
int serving
Definition: dis.c:46
unsigned service_id
Definition: db_dim_client.c:22
int to_delete
Definition: dis.c:89
char str[80]
Definition: test_client.c:7
void * id_get_ptr(int id, SRC_TYPES type)
Definition: conn_handler.c:184
void do_dis_stop_serving_dns(DIS_DNS_CONN *dnsp)
Definition: dis.c:2222
char name[MAX_NAME]
Definition: dis.c:72
int dna_close(int conn_id)
Definition: dna.c:835
int dis_n_services
Definition: dis.c:43
struct req_ent * prev
Definition: dis.c:54
int dis_hash_service_remove(SERVICE *servp)
Definition: dis.c:3283
void unregister_service(DIS_DNS_CONN *dnsp, SERVICE *servp)
Definition: dis.c:977
struct reqp_ent * reqpp
Definition: dis.c:66
Definition: dim.h:530
int delay_delete
Definition: dis.c:88
Definition: dis.c:69
REQUEST * request_head
Definition: dis.c:86
#define DIMSVCINVAL
Definition: dim_common.h:290
static int Dis_conn_id
Definition: dis.c:122
int release_request(REQUEST *reqp, REQUEST_PTR *reqpp, int remove)
Definition: dis.c:2650
void id_free(int id, SRC_TYPES type)
Definition: conn_handler.c:206
void free(void *mem)
DLL * dll_get_next(DLL *head, DLL *item)
Definition: dll.c:66
Definition: dis.c:92
void dim_print_date_time()
Definition: utilities.c:134
int req_id
Definition: dis.c:57
static int Debug_on
Definition: dis.c:156
unsigned int dis_service_id
Definition: dis.c:47
unsigned int dis_client_id
Definition: dis.c:48
void remove_service(int req_id)
Definition: dis.c:1558
Definition: dis.c:52
sprintf(name1,"NewService%d", i)
int id
Definition: dis.c:73

+ Here is the call graph for this function:

+ Here is the caller graph for this function: