FACT++  1.0
void check_validity ( int  conn_id)

Definition at line 610 of file dns.c.

References node::conn_id, Debug, dim_print_date_time(), dna_write_nowait(), Dns_conns, DNS_DIS_HEADER, DNS_DIS_REGISTER, Net_conns, release_conn(), set_in_error(), DNS_DIS_PACKET::size, time, DNS_DIS_PACKET::type, DNS_CONNECTION::validity, and WATCHDOG_TMOUT_MAX.

Referenced by handle_registration().

611 {
612  int time_diff;
613  DNS_DIS_PACKET dis_packet;
614  void set_in_error();
615 
616  if(Dns_conns[conn_id].validity < 0)
617  {
618  /* timeout reached kill all services and connection */
619  if(Dns_conns[conn_id].n_services != -1)
620  {
622  printf(" Server %s (%s@%s) has been set in error\n",
623  Dns_conns[conn_id].task_name, Net_conns[conn_id].task, Net_conns[conn_id].node);
624  fflush(stdout);
625  set_in_error(conn_id);
626  return;
627  }
628 /*
629  Dns_conns[conn_id].validity = -Dns_conns[conn_id].validity;
630 */
631  }
632  time_diff = (int)time(NULL) - Dns_conns[conn_id].validity;
633  if(time_diff > (int)(WATCHDOG_TMOUT_MAX*1.2))
634  {
635  /* send register signal */
636  dis_packet.type = htovl(DNS_DIS_REGISTER);
637  dis_packet.size = htovl(DNS_DIS_HEADER);
638  if(Debug)
639  {
641  printf(" Conn %3d : Server %s@%s Registration Requested\n",
642  conn_id, Net_conns[conn_id].task, Net_conns[conn_id].node);
643  fflush(stdout);
644  }
645 /* moved from dna_write to dna_write_nowait in 14/10/2008 */
646  if( !dna_write_nowait(conn_id, &dis_packet, DNS_DIS_HEADER) )
647  {
649  printf(" Server Validity: Couldn't write, releasing Conn %3d : Server %s@%s\n",conn_id,
650  Net_conns[conn_id].task, Net_conns[conn_id].node);
651  fflush(stdout);
652  release_conn(conn_id);
653  }
654  else
655  Dns_conns[conn_id].validity = -Dns_conns[conn_id].validity;
656  }
657 }
Definition: dns.c:26
static void release_conn(int conn_id)
Definition: dns.c:1077
DllExp DIM_NOSHARE DNS_CONNECTION * Dns_conns
Definition: conn_handler.c:29
DllExp DIM_NOSHARE NET_CONNECTION * Net_conns
Definition: conn_handler.c:32
int type
Definition: dim.h:288
#define DNS_DIS_HEADER
Definition: dim.h:291
void set_in_error(int conn_id)
Definition: dns.c:1199
int size
Definition: dim.h:287
int validity
Definition: dim.h:439
Warning because the service this data corrsponds to might have been last updated longer ago than Local time
Definition: smartfact.txt:92
#define WATCHDOG_TMOUT_MAX
Definition: dim.h:175
int dna_write_nowait(int conn_id, void *buffer, int size)
Definition: dna.c:412
void dim_print_date_time()
Definition: utilities.c:134
static int Debug
Definition: dns.c:78

+ Here is the call graph for this function:

+ Here is the caller graph for this function: