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

Definition at line 1093 of file dis.c.

References ALL, create_dns(), Debug_on, Default_DNS, DIM_FATAL, dim_print_date_time(), 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().

1094 {
1095  char str0[MAX_NAME], str1[MAX_NAME],str2[MAX_NAME],
1096  str3[MAX_NAME],str4[MAX_NAME];
1097  char task_name_aux[MAX_TASK_NAME];
1098  extern int open_dns();
1100  DIS_DNS_CONN *dnsp;
1101  unsigned int more_ids[10] = {0};
1102 
1103  dis_init();
1104  {
1105  DISABLE_AST
1106  if(Serving == -1)
1107  {
1108  ENABLE_AST
1109  return(0);
1110  }
1111  /*
1112 #ifdef VxWorks
1113  taskDeleteHookAdd(remove_all_services);
1114  printf("Adding delete hook\n");
1115 #endif
1116 */
1117 
1118  if(!Client_head)
1119  {
1120  Client_head = (CLIENT *)malloc(sizeof(CLIENT));
1121  dll_init( (DLL *) Client_head );
1122  }
1123  if(dnsid == 0)
1124  {
1125  dnsp = Default_DNS;
1126  }
1127  else if(!(dnsp = dis_find_dns(dnsid)))
1128  {
1129  dnsp = create_dns(dnsid);
1130  }
1131  dnsp->serving = 1;
1132  Serving = 1;
1133  if(Dis_first_time)
1134  {
1135  strncpy( task_name_aux, task, (size_t)MAX_TASK_NAME );
1136  task_name_aux[MAX_TASK_NAME-1] = '\0';
1138 if(Debug_on)
1139 {
1141  printf("Opening Server Connection %s\n",task_name_aux);
1142 }
1143  if( !(Dis_conn_id = dna_open_server( task_name_aux, dis_insert_request,
1145  {
1146  ENABLE_AST
1147  return(0);
1148  }
1149  Dis_first_time = 0;
1150  }
1151  if(dnsp->dis_first_time)
1152  {
1153  dnsp->dis_first_time = 0;
1154 
1155  sprintf(str0, "%s/VERSION_NUMBER", task);
1156  sprintf(str1, "%s/CLIENT_LIST", task);
1157  sprintf(str2, "%s/SERVICE_LIST", task);
1158  sprintf(str3, "%s/SET_EXIT_HANDLER", task);
1159  sprintf(str4, "%s/EXIT", task);
1160 
1161  more_ids[0] = do_dis_add_service_dns( str0, "L", &Version_number,
1162  sizeof(Version_number), 0, 0, dnsid );
1163 
1164  more_ids[1] = do_dis_add_service_dns( str1, "C", 0, 0, client_info, (dim_long)dnsp, dnsid );
1165  dnsp->dis_client_id = more_ids[1];
1166  more_ids[2] = do_dis_add_service_dns( str2, "C", 0, 0, service_info, (dim_long)dnsp, dnsid );
1167  dnsp->dis_service_id = more_ids[2];
1168  more_ids[3] = do_dis_add_cmnd_dns( str3, "L:1", add_exit_handler, 0, dnsid );
1169  more_ids[4] = do_dis_add_cmnd_dns( str4, "L:1", exit_handler, 0, dnsid );
1170  more_ids[5] = 0;
1171  strcpy( dnsp->task_name, task );
1172 if(Debug_on)
1173 {
1175  printf("start serving %s\n",task);
1176 }
1177  }
1178 /*
1179  if(idlist)
1180  {
1181  for(i = 0; idlist[i]; i++)
1182  {
1183  servp = (SERVICE *)id_get_ptr(idlist[i], SRC_DIS);
1184  if(servp)
1185  {
1186  servp->dnsp = dnsp;
1187  n_services++;
1188  }
1189  }
1190  }
1191  if(dnsp != Default_DNS)
1192  {
1193  for(i = 0; more_ids[i]; i++)
1194  {
1195  servp = (SERVICE *)id_get_ptr(more_ids[i], SRC_DIS);
1196  if(servp)
1197  {
1198  servp->dnsp = dnsp;
1199  n_services++;
1200  }
1201  }
1202  dnsp->dis_n_services += n_services;
1203  Dis_n_services -= n_services;
1204  }
1205 */
1206  if(!Dis_timer_q)
1207  Dis_timer_q = dtq_create();
1208  if( !dnsp->dns_dis_conn_id )
1209  {
1210  if(!strcmp(task,"DIS_DNS"))
1211  {
1212  register_services(dnsp, ALL, 1);
1213  ENABLE_AST
1214  return(id_get(&(dnsp->dis_dns_packet), SRC_DIS));
1215  }
1216  else
1217  {
1218 
1221  if(dnsp->dns_dis_conn_id == -2)
1222  error_handler(0, DIM_FATAL, DIMDNSUNDEF, "DIM_DNS_NODE undefined", -1);
1223  }
1224  }
1225  else
1226  {
1227  register_services(dnsp, MORE, 0);
1228  if(dnsp->dis_service_id)
1229  {
1230 /*
1231  dis_update_service(Dis_service_id);
1232 */
1233  if(!dnsp->updating_service_list)
1234  {
1236  dnsp->updating_service_list = 1;
1237  }
1238  }
1239  }
1240  ENABLE_AST
1241  }
1242  return(1);
1243 }
DIS_DNS_CONN * Default_DNS
Definition: dis.c:129
#define MAX_NAME
Definition: dim.h:182
static void error_handler(int conn_id, int severity, int errcode, char *reason, int exit)
Definition: dis.c:3199
static int Protocol
Definition: dis.c:120
int serving
Definition: dis.c:46
int dns_dis_conn_id
Definition: dis.c:44
void service_info(dim_long *tag, int **bufp, int *size, int *first_time)
Definition: dis.c:2956
char task_name[MAX_NAME]
Definition: dis.c:40
Definition: dis.c:98
int dtq_create()
Definition: dtq.c:353
void * malloc()
Definition: EventBuilder.cc:99
#define DIS_DNS_TMOUT_MAX
Definition: dim.h:157
void dll_init(DLL *head)
Definition: dll.c:14
void add_exit_handler(int *tag, int *bufp, int *size)
Definition: dis.c:3116
static void dis_insert_request(int conn_id, DIC_PACKET *dic_packet, int size, int status)
Definition: dis.c:1251
void register_services(DIS_DNS_CONN *dnsp, int flag, int dns_flag)
Definition: dis.c:812
int updating_service_list
Definition: dis.c:49
#define DIS_DNS_TMOUT_MIN
Definition: dim.h:156
void do_update_service_list(DIS_DNS_CONN *dnsp)
Definition: dis.c:1029
#define DIMDNSUNDEF
Definition: dim_common.h:282
static CLIENT * Client_head
Definition: dis.c:106
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
Definition: dim.h:530
void dtq_start_timer(int time, void(*user_routine)(), dim_long tag)
Definition: dtq.c:790
static int Dis_timer_q
Definition: dis.c:143
static int Dis_first_time
Definition: dis.c:116
#define MORE
Definition: dis.c:33
static DIS_DNS_CONN * create_dns(dim_long dnsid)
Definition: dis.c:1047
#define MAX_TASK_NAME
Definition: dim.h:181
long dim_long
Definition: dim_common.h:57
static unsigned do_dis_add_cmnd_dns(char *name, char *type, void(*user_routine)(), dim_long tag, dim_long dnsid)
Definition: dis.c:413
void client_info(dim_long *tag, int **bufp, int *size, int *first_time)
Definition: dis.c:2832
int dis_first_time
Definition: dis.c:45
DIS_DNS_CONN * dis_find_dns(dim_long dnsid)
Definition: dis.c:3360
static int Port_number
Definition: dis.c:121
static int Dis_conn_id
Definition: dis.c:122
void recv_dns_dis_rout(int conn_id, DNS_DIS_PACKET *packet, int size, int status)
Definition: dis.c:641
static int Version_number
Definition: dis.c:142
int dna_open_server(char *task, void(*read_ast)(), int *protocol, int *port, void(*error_ast)())
Definition: dna.c:551
static void exit_handler(int *tag, int *bufp, int *size)
Definition: dis.c:3183
static unsigned do_dis_add_service_dns(char *name, char *type, void *address, int size, void(*user_routine)(), dim_long tag, dim_long dnsid)
Definition: dis.c:234
#define ALL
Definition: dis.c:32
void dis_init()
Definition: dis.c:220
int id_get(void *ptr, SRC_TYPES type)
Definition: conn_handler.c:152
void dim_print_date_time()
Definition: utilities.c:134
static int Debug_on
Definition: dis.c:156
unsigned int dis_service_id
Definition: dis.c:47
int more_ids[1024]
Definition: test_server.c:56
static int Serving
Definition: dis.c:124
#define SEEK_PORT
Definition: dim.h:140
unsigned int dis_client_id
Definition: dis.c:48
dnsid
Definition: README_v19.txt:372
DIS_DNS_PACKET dis_dns_packet
Definition: dis.c:42
sprintf(name1,"NewService%d", i)

+ Here is the call graph for this function:

+ Here is the caller graph for this function: