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

Definition at line 304 of file webDid.c.

References item::busy, find_node(), find_server(), First_time, Memory::free(), item::isSMI, JSONHeader, Memory::malloc(), MAX_NAME, MAX_TASK_NAME, DNS_SERVICE_INFO::n_clients, N_nodes, N_servers, bitem::n_services, N_services, DNS_SERVER_INFO::n_services, item::name, DNS_SERVICE_INFO::name, item::next, DNS_SERVER_INFO::node, DNS_SERVER_INFO::pid, prepareJSONHeader(), prepareJSONTree(), item::server, DNS_DID::server, item::service_ptr, DNS_DID::services, sll_init(), sll_insert_queue(), DNS_SERVICE_INFO::status, str, DNS_SERVER_INFO::task, and DNS_SERVICE_INFO::type.

Referenced by did_init().

305 {
306 int n_services, service_size;
307 SERVER *servp;
308 NODE *nodep;
309 int j;
310 char str[MAX_NAME], sname[MAX_NAME], *ptr;
311 int prepareJSONTree();
312 int prepareJSONHeader();
313 
314  if(tag){}
315  if(!Node_head)
316  {
317  Node_head = (NODE *)malloc(sizeof(NODE));
318  sll_init((SLL *)Node_head);
319  }
320  if(First_time)
321  {
322  First_time = 0;
323  }
324 
325  if(!*size)
326  return;
327  if(*(char *)buffer == -1)
328  {
329  N_servers = 0;
330  N_services = 0;
331  return;
332  }
333  buffer->server.n_services = vtohl(buffer->server.n_services);
334  buffer->server.pid = vtohl(buffer->server.pid);
335  n_services = buffer->server.n_services;
336 
337  if(n_services == 1)
338  return;
339  strcpy(sname, buffer->server.task);
340  if(n_services > 1)
341  {
342  for(j = 0; j < n_services; j++)
343  {
344  buffer->services[j].type = vtohl(
345  buffer->services[j].type);
346  buffer->services[j].status = vtohl(
347  buffer->services[j].status);
348  buffer->services[j].n_clients = vtohl(
349  buffer->services[j].n_clients);
350  if((int)strlen(sname) == MAX_TASK_NAME-4-1)
351  {
352  strcpy(str,buffer->services[j].name);
353  if( (ptr = strstr(str,"/CLIENT_LIST")) )
354  {
355  *ptr = '\0';
356  strcpy(sname,str);
357  }
358  }
359  }
360  }
361  if (!(nodep = find_node(buffer->server.node)))
362  {
363  if(n_services)
364  {
365  N_nodes++;
366  nodep = (NODE *)malloc(sizeof(NODE));
367  strcpy(nodep->name,buffer->server.node);
368  nodep->hasSMI = 0;
369  nodep->server_head = (SERVER *)malloc(sizeof(SERVER));
370  sll_init((SLL *)nodep->server_head);
371  sll_insert_queue((SLL *)Node_head,(SLL *)nodep);
372  }
373  }
374  if (!(servp = find_server(nodep,buffer->server.pid)))
375  {
376  if(n_services)
377  {
378  servp = (SERVER *)malloc(sizeof(SERVER));
379  strcpy(servp->name,sname);
380  servp->next = 0;
381  servp->busy = 0;
382  servp->server.n_services = 0;
383  servp->service_ptr = 0;
384  servp->isSMI = 0;
385  if(strstr(sname,"_SMI"))
386  {
387  servp->isSMI = 1;
388  nodep->hasSMI = 1;
389  }
390  sll_insert_queue((SLL *)nodep->server_head,(SLL *)servp);
391  }
392  }
393  if(n_services != 0)
394  {
395  if(n_services == servp->server.n_services)
396  {
397  return;
398  }
399  if(servp->server.n_services == 0)
400  N_servers++;
401  if(servp->server.n_services != -1)
402  N_services -= servp->server.n_services;
403  memcpy(&servp->server,&buffer->server,sizeof(DNS_SERVER_INFO));
404  if(servp->service_ptr)
405  {
406  free(servp->service_ptr);
407  servp->service_ptr = 0;
408  }
409  if(n_services != -1)
410  {
411  service_size = n_services*(int)sizeof(DNS_SERVICE_INFO);
412  servp->service_ptr = (DNS_SERVICE_INFO *)malloc((size_t)service_size);
413  memcpy(servp->service_ptr, buffer->services, (size_t)service_size);
414  N_services += n_services;
415  }
416  servp->busy = 1;
417  }
418  else
419  {
420  if(servp)
421  {
422  N_servers--;
423  if(servp->server.n_services != -1)
424  {
425  N_services -= servp->server.n_services;
426  }
427  servp->server.n_services = 0;
428  servp->busy = -1;
429  servp->isSMI = 0;
430  }
431  }
432  if(JSONHeader[0])
434 }
NODE * Node_head
Definition: webDid.c:28
#define MAX_NAME
Definition: dim.h:182
Definition: dns.c:26
int N_servers
Definition: webDid.c:105
int N_services
Definition: webDid.c:106
int busy
Definition: did.h:52
Definition: did.h:42
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
char task[MAX_TASK_NAME]
Definition: dim.h:339
char name[132]
Definition: did.h:46
DNS_SERVER_INFO server
Definition: dim.h:345
int prepareJSONTree(char *node, BROWSER *browserp)
Definition: webDid.c:1493
Definition: dim.h:536
int isSMI
Definition: webDid.c:17
void sll_init(SLL *head)
Definition: sll.c:14
int sll_insert_queue(SLL *head, SLL *item)
Definition: sll.c:20
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
char JSONHeader[256]
Definition: webDid.c:92
int size
Definition: db_dim_server.c:17
void free(void *mem)
SERVER * find_server(NODE *nodep, int pid)
Definition: webDid.c:157
int n_services
Definition: dim.h:341
int First_time
Definition: webDid.c:98
NODE * find_node(char *node)
Definition: webDid.c:174
int N_nodes
Definition: webDid.c:104
DNS_SERVICE_INFO services[1]
Definition: dim.h:346
int prepareJSONHeader()
Definition: webDid.c:1819

+ Here is the call graph for this function:

+ Here is the caller graph for this function: