FACT++  1.0
void update_servers ( int *  tag,
DNS_DID buffer,
int *  size 
)

Definition at line 2313 of file did.c.

References item::busy, item::button_id, find_server(), First_time, Force_update, Memory::free(), Memory::malloc(), MAX_NAME, MAX_TASK_NAME, DNS_SERVICE_INFO::n_clients, N_servers, N_services, DNS_SERVER_INFO::n_services, item::name, DNS_SERVICE_INFO::name, item::next, DNS_SERVER_INFO::node, DNS_SERVER_INFO::pid, item::pop_widget_id, item::server, DNS_DID::server, Server_head, item::service_ptr, DNS_DID::services, sll_init(), sll_insert_queue(), DNS_SERVICE_INFO::status, str, switch_matrix(), DNS_SERVER_INFO::task, and DNS_SERVICE_INFO::type.

Referenced by app_initialize().

2314 {
2315 int n_services, service_size;
2316 SERVER *servp;
2317 int j;
2318 char str[MAX_NAME], sname[MAX_NAME], *ptr;
2319 
2320  if(tag){}
2321  if(!Server_head)
2322  {
2323  Server_head = (SERVER *)malloc(sizeof(SERVER));
2324  sll_init((SLL *)Server_head);
2325  }
2326  if(First_time)
2327  {
2328  switch_matrix();
2329  First_time = 0;
2330  }
2331 
2332  if(!*size)
2333  return;
2334  if(*(char *)buffer == -1)
2335  {
2336  N_servers = 0;
2337  N_services = 0;
2338  return;
2339  }
2340  buffer->server.n_services = vtohl(buffer->server.n_services);
2341  buffer->server.pid = vtohl(buffer->server.pid);
2342  n_services = buffer->server.n_services;
2343  /*
2344 printf("received pid %d, nservices %d\n",buffer->server.pid, n_services);
2345  */
2346  if(n_services == 1)
2347  return;
2348  strcpy(sname, buffer->server.task);
2349  /*
2350 printf("name = %s\n", sname);
2351  */
2352  if(n_services > 1)
2353  {
2354  for(j = 0; j < n_services; j++)
2355  {
2356  buffer->services[j].type = vtohl(
2357  buffer->services[j].type);
2358  buffer->services[j].status = vtohl(
2359  buffer->services[j].status);
2360  buffer->services[j].n_clients = vtohl(
2361  buffer->services[j].n_clients);
2362  if(strlen(sname) == MAX_TASK_NAME-4-1)
2363  {
2364  strcpy(str,buffer->services[j].name);
2365  if( (ptr = strstr(str,"/CLIENT_LIST")) )
2366  {
2367  *ptr = '\0';
2368  strcpy(sname,str);
2369  }
2370  }
2371  }
2372  }
2373  if (!(servp = find_server(buffer->server.node,buffer->server.pid)))
2374  /*
2375  if(!(servp = (SERVER *)sll_search((SLL *)Server_head,
2376  (char *)&buffer->server, MAX_NODE_NAME+MAX_TASK_NAME-4)))
2377  */
2378  {
2379  if(n_services)
2380  {
2381  servp = (SERVER *)malloc(sizeof(SERVER));
2382  strcpy(servp->name,sname);
2383  servp->next = 0;
2384  servp->button_id = 0;
2385  servp->pop_widget_id[0] = 0;
2386  servp->pop_widget_id[1] = 0;
2387  servp->busy = 0;
2388  servp->server.n_services = 0;
2389  servp->service_ptr = 0;
2390  sll_insert_queue((SLL *)Server_head,(SLL *)servp);
2391  }
2392  }
2393  if(n_services != 0)
2394  {
2395  if(n_services == servp->server.n_services)
2396  {
2397  return;
2398  }
2399  if(servp->server.n_services == 0)
2400  N_servers++;
2401  if(servp->server.n_services != -1)
2402  N_services -= servp->server.n_services;
2403  memcpy(&servp->server,&buffer->server,sizeof(DNS_SERVER_INFO));
2404  if(servp->service_ptr)
2405  {
2406  free(servp->service_ptr);
2407  servp->service_ptr = 0;
2408  }
2409  if(n_services != -1)
2410  {
2411  service_size = n_services*(int)sizeof(DNS_SERVICE_INFO);
2412  servp->service_ptr = (DNS_SERVICE_INFO *)malloc((size_t)service_size);
2413  memcpy(servp->service_ptr, buffer->services, (size_t)service_size);
2414  N_services += n_services;
2415  }
2416  servp->busy = 1;
2417  if(strcmp(servp->name, sname))
2418  {
2419  strcpy(servp->name,sname);
2420  Force_update = 1;
2421  servp->busy = 3;
2422  }
2423  }
2424  else
2425  {
2426  if(servp)
2427  {
2428  N_servers--;
2429  if(servp->server.n_services != -1)
2430  {
2431  N_services -= servp->server.n_services;
2432  }
2433  else
2434  Force_update = 1;
2435  servp->server.n_services = 0;
2436  servp->busy = -1;
2437  }
2438  }
2439 }
#define MAX_NAME
Definition: dim.h:182
int N_services
Definition: did.c:16
int busy
Definition: did.h:52
Definition: did.h:42
Widget button_id
Definition: did.h:47
char str[80]
Definition: test_client.c:7
char node[MAX_NODE_NAME]
Definition: dim.h:338
int n_clients
Definition: dim.h:334
void * malloc()
Definition: EventBuilder.cc:99
int Force_update
Definition: did.c:36
char task[MAX_TASK_NAME]
Definition: dim.h:339
SERVER * Server_head
Definition: did.h:55
char name[132]
Definition: did.h:46
DNS_SERVER_INFO server
Definition: dim.h:345
int First_time
Definition: did.c:9
Definition: dim.h:536
Widget pop_widget_id[2]
Definition: did.h:48
void sll_init(SLL *head)
Definition: sll.c:14
int sll_insert_queue(SLL *head, SLL *item)
Definition: sll.c:20
SERVER * find_server(char *node, int pid)
Definition: did.c:2291
DNS_SERVICE_INFO * service_ptr
Definition: did.h:45
char name[MAX_NAME]
Definition: dim.h:331
#define MAX_TASK_NAME
Definition: dim.h:181
struct item * next
Definition: did.h:43
DNS_SERVER_INFO server
Definition: did.h:44
int status
Definition: dim.h:333
int size
Definition: db_dim_server.c:17
void free(void *mem)
void switch_matrix()
Definition: did.c:2269
int n_services
Definition: dim.h:341
DNS_SERVICE_INFO services[1]
Definition: dim.h:346
int N_servers
Definition: did.c:15

+ Here is the call graph for this function:

+ Here is the caller graph for this function: