FACT++  1.0
int dis_start_serving_dns ( long  dnsid,
char *  task 
)

Definition at line 1003 of file dis_old.c.

References ALL, create_dns(), Default_DNS, DIM_FATAL, DIMDNSUNDEF, Dis_conn_id, dis_dns_ent::dis_dns_packet, DIS_DNS_TMOUT_MAX, DIS_DNS_TMOUT_MIN, dis_find_dns(), dis_dns_ent::dis_first_time, Dis_first_time, dis_init(), dis_dns_ent::dis_service_id, Dis_timer_q, dll_init(), dna_open_server(), dis_dns_ent::dns_dis_conn_id, do_dis_add_cmnd_dns(), do_dis_add_service_dns(), do_update_service_list(), dtq_create(), dtq_start_timer(), error_handler(), id_get(), Memory::malloc(), MAX_NAME, MAX_TASK_NAME, MORE, more_ids, open_dns(), Port_number, Protocol, recv_dns_dis_rout(), register_services(), SEEK_PORT, dis_dns_ent::serving, Serving, sprintf(), SRC_DIS, dis_dns_ent::updating_service_list, and Version_number.

Referenced by dis_start_serving().

1004 {
1005  char str0[MAX_NAME], str1[MAX_NAME],str2[MAX_NAME],
1006  str3[MAX_NAME],str4[MAX_NAME];
1007  char task_name_aux[MAX_TASK_NAME];
1008  extern int open_dns();
1009  extern DIS_DNS_CONN *dis_find_dns(long);
1010  DIS_DNS_CONN *dnsp;
1011  int more_ids[10] = {0};
1012 
1013  dis_init();
1014  {
1015  DISABLE_AST
1016  /*
1017 #ifdef VxWorks
1018  taskDeleteHookAdd(remove_all_services);
1019  printf("Adding delete hook\n");
1020 #endif
1021 */
1022 
1023  if(!Client_head)
1024  {
1025  Client_head = (CLIENT *)malloc(sizeof(CLIENT));
1026  dll_init( (DLL *) Client_head );
1027  }
1028  if(dnsid == 0)
1029  {
1030  dnsp = Default_DNS;
1031  }
1032  else if(!(dnsp = dis_find_dns(dnsid)))
1033  {
1034  dnsp = create_dns(dnsid);
1035  }
1036  dnsp->serving = 1;
1037  Serving = 1;
1038  if(Dis_first_time)
1039  {
1040  strncpy( task_name_aux, task, MAX_TASK_NAME );
1041  task_name_aux[MAX_TASK_NAME-1] = '\0';
1043  if( !(Dis_conn_id = dna_open_server( task_name_aux, dis_insert_request,
1045  {
1046  ENABLE_AST
1047  return(0);
1048  }
1049  Dis_first_time = 0;
1050  }
1051  if(dnsp->dis_first_time)
1052  {
1053  dnsp->dis_first_time = 0;
1054 
1055  sprintf(str0, "%s/VERSION_NUMBER", task);
1056  sprintf(str1, "%s/CLIENT_LIST", task);
1057  sprintf(str2, "%s/SERVICE_LIST", task);
1058  sprintf(str3, "%s/SET_EXIT_HANDLER", task);
1059  sprintf(str4, "%s/EXIT", task);
1060 
1061  more_ids[0] = do_dis_add_service_dns( str0, "L", &Version_number,
1062  sizeof(Version_number), 0, 0, dnsid );
1063 
1064  more_ids[1] = do_dis_add_service_dns( str1, "C", 0, 0, client_info, (long)dnsp, dnsid );
1065  dnsp->dis_client_id = more_ids[1];
1066  more_ids[2] = do_dis_add_service_dns( str2, "C", 0, 0, service_info, (long)dnsp, dnsid );
1067  dnsp->dis_service_id = more_ids[2];
1068  more_ids[3] = do_dis_add_cmnd_dns( str3, "L:1", add_exit_handler, 0, dnsid );
1069  more_ids[4] = do_dis_add_cmnd_dns( str4, "L:1", exit_handler, 0, dnsid );
1070  more_ids[5] = 0;
1071  strcpy( dnsp->task_name, task );
1072  }
1073 /*
1074  if(idlist)
1075  {
1076  for(i = 0; idlist[i]; i++)
1077  {
1078  servp = (SERVICE *)id_get_ptr(idlist[i], SRC_DIS);
1079  if(servp)
1080  {
1081  servp->dnsp = dnsp;
1082  n_services++;
1083  }
1084  }
1085  }
1086  if(dnsp != Default_DNS)
1087  {
1088  for(i = 0; more_ids[i]; i++)
1089  {
1090  servp = (SERVICE *)id_get_ptr(more_ids[i], SRC_DIS);
1091  if(servp)
1092  {
1093  servp->dnsp = dnsp;
1094  n_services++;
1095  }
1096  }
1097  dnsp->dis_n_services += n_services;
1098  Dis_n_services -= n_services;
1099  }
1100 */
1101  if(!Dis_timer_q)
1102  Dis_timer_q = dtq_create();
1103  if( !dnsp->dns_dis_conn_id )
1104  {
1105  if(!strcmp(task,"DIS_DNS"))
1106  {
1107  register_services(dnsp, ALL, 1);
1108  ENABLE_AST
1109  return(id_get(&(dnsp->dis_dns_packet), SRC_DIS));
1110  }
1111  else
1112  {
1113 
1116  if(dnsp->dns_dis_conn_id == -2)
1117  error_handler(0, DIM_FATAL, DIMDNSUNDEF, "DIM_DNS_NODE undefined");
1118  }
1119  }
1120  else
1121  {
1122  register_services(dnsp, MORE, 0);
1123  if(dnsp->dis_service_id)
1124  {
1125 /*
1126  dis_update_service(Dis_service_id);
1127 */
1128  if(!dnsp->updating_service_list)
1129  {
1131  dnsp->updating_service_list = 1;
1132  }
1133  }
1134  }
1135  ENABLE_AST
1136  }
1137  return(1);
1138 }
#define MAX_NAME
Definition: dim.h:182
int serving
Definition: dis.c:46
int dns_dis_conn_id
Definition: dis.c:44
#define ALL
Definition: dis_old.c:32
static int Dis_timer_q
Definition: dis_old.c:141
void add_exit_handler(int *tag, int *bufp, int *size)
Definition: dis_old.c:2719
void register_services(DIS_DNS_CONN *dnsp, int flag, int dns_flag)
Definition: dis_old.c:763
static int Port_number
Definition: dis_old.c:121
static void exit_handler(int *tag, int *bufp, int *size)
Definition: dis_old.c:2811
char task_name[MAX_NAME]
Definition: dis.c:40
void recv_dns_dis_rout(int conn_id, DNS_DIS_PACKET *packet, int size, int status)
Definition: dis_old.c:622
DIS_DNS_CONN * dis_find_dns(long dnsid)
Definition: dis_old.c:2962
void client_info(long *tag, int **bufp, int *size, int *first_time)
Definition: dis_old.c:2522
Definition: dis.c:98
int dtq_create()
Definition: dtq.c:353
static CLIENT * Client_head
Definition: dis_old.c:106
static void dis_insert_request(int conn_id, DIC_PACKET *dic_packet, int size, int status)
Definition: dis_old.c:1146
void * malloc()
Definition: EventBuilder.cc:99
#define DIS_DNS_TMOUT_MAX
Definition: dim.h:157
void dll_init(DLL *head)
Definition: dll.c:14
DIS_DNS_CONN * Default_DNS
Definition: dis_old.c:129
#define MORE
Definition: dis_old.c:33
void do_update_service_list(DIS_DNS_CONN *dnsp)
Definition: dis_old.c:940
int updating_service_list
Definition: dis.c:49
#define DIS_DNS_TMOUT_MIN
Definition: dim.h:156
static int Protocol
Definition: dis_old.c:120
static int Dis_first_time
Definition: dis_old.c:116
static int Version_number
Definition: dis_old.c:140
#define DIMDNSUNDEF
Definition: dim_common.h:282
static void dis_init()
Definition: dis_old.c:216
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
static unsigned do_dis_add_cmnd_dns(char *name, char *type, void(*user_routine)(), long tag, long dnsid)
Definition: dis_old.c:403
Definition: dim.h:530
void dtq_start_timer(int time, void(*user_routine)(), dim_long tag)
Definition: dtq.c:790
void service_info(long *tag, int **bufp, int *size, int *first_time)
Definition: dis_old.c:2646
#define MAX_TASK_NAME
Definition: dim.h:181
int dis_first_time
Definition: dis.c:45
int dna_open_server(char *task, void(*read_ast)(), int *protocol, int *port, void(*error_ast)())
Definition: dna.c:551
static void error_handler(int conn_id, int severity, int errcode, char *reason)
Definition: dis_old.c:2827
static int Serving
Definition: dis_old.c:124
int id_get(void *ptr, SRC_TYPES type)
Definition: conn_handler.c:152
unsigned int dis_service_id
Definition: dis.c:47
int more_ids[1024]
Definition: test_server.c:56
#define SEEK_PORT
Definition: dim.h:140
unsigned int dis_client_id
Definition: dis.c:48
dnsid
Definition: README_v19.txt:372
static unsigned do_dis_add_service_dns(char *name, char *type, void *address, int size, void(*user_routine)(), long tag, long dnsid)
Definition: dis_old.c:229
static int Dis_conn_id
Definition: dis_old.c:122
DIS_DNS_PACKET dis_dns_packet
Definition: dis.c:42
sprintf(name1,"NewService%d", i)
static DIS_DNS_CONN * create_dns(long dnsid)
Definition: dis_old.c:957

+ Here is the call graph for this function:

+ Here is the caller graph for this function: