FACT++  1.0
void recv_dns_dis_rout ( int  conn_id,
DNS_DIS_PACKET packet,
int  size,
int  status 
)

Definition at line 641 of file dis.c.

References ALL, exit_ent::conn_id, DIM_FATAL, DIM_WARNING, DIMDNSDUPLC, DIMDNSEXIT, DIMDNSREFUS, DIMDNSTMOUT, DIMDNSUNDEF, DIS_DNS_TMOUT_MAX, DIS_DNS_TMOUT_MIN, Dis_timer_q, dna_close(), dis_dns_ent::dns_dis_conn_id, DNS_DIS_EXIT, DNS_DIS_HEADER, DNS_DIS_KILL, DNS_DIS_REGISTER, DNS_DIS_SOFT_EXIT, DNS_DIS_STOP, dis_dns_ent::dns_timr_ent, dis_dns_ent::dnsid, do_dis_stop_serving_dns(), do_register_services(), dtq_add_entry(), dtq_rem_entry(), error_handler(), find_dns_by_conn_id(), open_dns(), rand_tmout(), register_services(), dis_dns_ent::serving, Serving, DNS_DIS_PACKET::size, sprintf(), SRC_DIS, STA_CONN, STA_DISC, str, dis_dns_ent::task_name, type, DNS_DIS_PACKET::type, WATCHDOG_TMOUT_MAX, and WATCHDOG_TMOUT_MIN.

Referenced by dis_start_serving_dns(), and release_conn().

642 {
643  char str[128];
644  int dns_timr_time;
645  extern int rand_tmout(int, int);
646  extern int open_dns(dim_long, void (*)(), void (*)(), int, int, int);
647  extern DIS_DNS_CONN *find_dns_by_conn_id(int);
648  extern void do_register_services(DIS_DNS_CONN *);
649  extern void do_dis_stop_serving_dns(DIS_DNS_CONN *);
650  DIS_DNS_CONN *dnsp;
651  int type, exit_code;
652 
653  if(size){}
654  dnsp = find_dns_by_conn_id(conn_id);
655  if(!dnsp)
656  {
657  return;
658  }
659  switch(status)
660  {
661  case STA_DISC: /* connection broken */
662  if( dnsp->dns_timr_ent ) {
664  dnsp->dns_timr_ent = NULL;
665  }
666 
667  if(dnsp->dns_dis_conn_id > 0)
668  dna_close(dnsp->dns_dis_conn_id);
669  if(Serving == -1)
670  return;
671  if(dnsp->serving)
672  {
675  if(dnsp->dns_dis_conn_id == -2)
676  error_handler(0, DIM_FATAL, DIMDNSUNDEF, "DIM_DNS_NODE undefined", -1);
677  }
678  break;
679  case STA_CONN: /* connection received */
680  if(dnsp->serving)
681  {
682  dnsp->dns_dis_conn_id = conn_id;
683  register_services(dnsp, ALL, 0);
684  dns_timr_time = rand_tmout(WATCHDOG_TMOUT_MIN,
687  dns_timr_time,
688  do_register_services, dnsp );
689  }
690  else
691  {
692  dna_close(conn_id);
693  }
694  break;
695  default : /* normal packet */
696  if(vtohl(packet->size) != DNS_DIS_HEADER)
697  break;
698  type = vtohl(packet->type);
699  exit_code = (type >> 16) & 0xFFFF;
700  type &= 0xFFFF;
701  switch(type)
702  {
703  case DNS_DIS_REGISTER :
704  sprintf(str,
705  "%s: Watchdog Timeout, DNS requests registration",
706  dnsp->task_name);
707  error_handler(0, DIM_WARNING, DIMDNSTMOUT, str, -1);
708  register_services(dnsp, ALL, 0);
709  break;
710  case DNS_DIS_KILL :
711  sprintf(str,
712  "%s: Some Services already known to DNS",
713  dnsp->task_name);
714  /*
715  exit(2);
716  */
717  Serving = -1;
718  error_handler(0, DIM_FATAL, DIMDNSDUPLC, str, -1);
719  /*
720  do_dis_stop_serving_dns(dnsp);
721  dis_stop_serving();
722  */
723 /*
724  exit_tag = 0;
725  exit_code = 2;
726  exit_size = sizeof(int);
727  exit_handler(&exit_tag, &exit_code, &exit_size);
728 */
729  break;
730  case DNS_DIS_STOP :
731  sprintf(str,
732  "%s: DNS refuses connection",dnsp->task_name);
733 /*
734  exit(2);
735 */
736  Serving = -1;
737  error_handler(0, DIM_FATAL, DIMDNSREFUS, str, -1);
738  /*
739  do_dis_stop_serving_dns(dnsp);
740  dis_stop_serving();
741  */
742 /*
743  exit_tag = 0;
744  exit_code = 2;
745  exit_size = sizeof(int);
746  exit_handler(&exit_tag, &exit_code, &exit_size);
747 */
748  break;
749  case DNS_DIS_EXIT :
750  sprintf(str,
751  "%s: DNS requests Exit",dnsp->task_name);
752 /*
753  Serving = -1;
754 */
755  error_handler(0, DIM_FATAL, DIMDNSEXIT, str, -1);
756  break;
757  case DNS_DIS_SOFT_EXIT :
758  sprintf(str,
759  "%s: DNS requests Exit(%d)",dnsp->task_name, exit_code);
760 /*
761  Serving = -1;
762 */
763  error_handler(0, DIM_FATAL, DIMDNSEXIT, str, exit_code);
764  break;
765  }
766  break;
767  }
768 }
#define DIMDNSTMOUT
Definition: dim_common.h:286
static void error_handler(int conn_id, int severity, int errcode, char *reason, int exit)
Definition: dis.c:3199
int serving
Definition: dis.c:46
int dns_dis_conn_id
Definition: dis.c:44
#define STA_DISC
Definition: dim.h:197
char task_name[MAX_NAME]
Definition: dis.c:40
char str[80]
Definition: test_client.c:7
DIS_DNS_CONN * find_dns_by_conn_id(int conn_id)
Definition: dis.c:3392
void do_dis_stop_serving_dns(DIS_DNS_CONN *dnsp)
Definition: dis.c:2222
#define DIMDNSEXIT
Definition: dim_common.h:285
int rand_tmout(int min, int max)
Definition: open_dns.c:161
int dna_close(int conn_id)
Definition: dna.c:835
int type
Definition: dim.h:288
#define DNS_DIS_HEADER
Definition: dim.h:291
#define DIS_DNS_TMOUT_MAX
Definition: dim.h:157
void register_services(DIS_DNS_CONN *dnsp, int flag, int dns_flag)
Definition: dis.c:812
#define DIS_DNS_TMOUT_MIN
Definition: dim.h:156
#define DIMDNSUNDEF
Definition: dim_common.h:282
dim_long dnsid
Definition: dis.c:39
int open_dns(dim_long dnsid, void(*recv_rout)(), void(*error_rout)(), int tmout_min, int tmout_max, SRC_TYPES src_type)
Definition: open_dns.c:313
int type
int size
Definition: dim.h:287
#define WATCHDOG_TMOUT_MIN
Definition: dim.h:174
static int Dis_timer_q
Definition: dis.c:143
int dtq_rem_entry(int queue_id, TIMR_ENT *entry)
Definition: dtq.c:503
TIMR_ENT * dns_timr_ent
Definition: dis.c:41
long dim_long
Definition: dim_common.h:57
#define DIMDNSDUPLC
Definition: dim_common.h:284
#define WATCHDOG_TMOUT_MAX
Definition: dim.h:175
void recv_dns_dis_rout(int conn_id, DNS_DIS_PACKET *packet, int size, int status)
Definition: dis.c:641
int size
Definition: db_dim_server.c:17
#define ALL
Definition: dis.c:32
TIMR_ENT * dtq_add_entry(int queue_id, int time, void(*user_routine)(), dim_long tag)
Definition: dtq.c:399
static int Serving
Definition: dis.c:124
sprintf(name1,"NewService%d", i)
#define DIMDNSREFUS
Definition: dim_common.h:283
#define STA_CONN
Definition: dim.h:199
void do_register_services(DIS_DNS_CONN *dnsp)
Definition: dis.c:807

+ Here is the call graph for this function:

+ Here is the caller graph for this function: