FACT++  1.0
static void dis_insert_request ( int  conn_id,
DIC_PACKET dic_packet,
int  size,
int  status 
)
static

Definition at line 1251 of file dis.c.

References COMMAND, req_ent::conn_id, exit_ent::conn_id, create_client(), Curr_conn_id, Debug_on, req_ent::delay_delete, DIM_DELETE, dim_print_date_time(), dis_dns_ent::dis_client_id, Dis_timer_q, dis_update_service(), dll_get_next(), dll_init(), dll_insert_queue(), cli_ent::dnsp, dtq_add_entry(), execute_command(), execute_service(), find_release_request(), find_service(), req_ent::first_time, req_ent::format, DIC_PACKET::format, Memory::free(), id_free(), id_get(), Last_client, Memory::malloc(), MONIT_FIRST, MONIT_ONLY, Net_conns, NET_CONNECTION::node, ONCE_ONLY, release_conn(), req_ent::req_id, reqp_ent::reqp, req_ent::reqpp, serv::request_head, cli_ent::requestp_head, req_ent::service_id, DIC_PACKET::service_id, DIC_PACKET::service_name, req_ent::service_ptr, SRC_DIS, exit_ent::task, NET_CONNECTION::task, req_ent::timeout, DIC_PACKET::timeout, req_ent::timr_ent, req_ent::to_delete, type, req_ent::type, DIC_PACKET::type, and UPDATE.

1252 {
1253  register SERVICE *servp;
1254  register REQUEST *newp, *reqp;
1255  CLIENT *clip, *create_client();
1256  REQUEST_PTR *reqpp;
1257  int type, new_client = 0, found = 0;
1258  int find_release_request();
1259  DIS_DNS_CONN *dnsp;
1260 
1261  if(size){}
1262  /* status = 1 => new connection, status = -1 => conn. lost */
1263  if(!Client_head)
1264  {
1265  Client_head = (CLIENT *)malloc(sizeof(CLIENT));
1266  dll_init( (DLL *) Client_head );
1267  }
1268  if(status != 0)
1269  {
1270  if(status == -1) /* release all requests from conn_id */
1271  {
1272 if(Debug_on)
1273 {
1275 printf("Received Disconnection %d, from %s@%s\n",
1276  conn_id,
1277  Net_conns[conn_id].task, Net_conns[conn_id].node);
1278 }
1279  release_conn(conn_id, 0, 0);
1280  }
1281  else
1282  {
1283 if(Debug_on)
1284 {
1286 printf("Received Connection %d, from %s@%s\n",
1287  conn_id,
1288  Net_conns[conn_id].task, Net_conns[conn_id].node);
1289 }
1290  }
1291  }
1292  else
1293  {
1294 if(Debug_on)
1295 {
1297 printf("Received Request for %s, from %d %s@%s\n",
1298  dic_packet->service_name, conn_id,
1299  Net_conns[conn_id].task, Net_conns[conn_id].node);
1300 }
1301  dic_packet->type = vtohl(dic_packet->type);
1302  type = dic_packet->type & 0xFFF;
1303  /*
1304  if(type == COMMAND)
1305  {
1306  Curr_conn_id = conn_id;
1307  execute_command(servp, dic_packet);
1308  Curr_conn_id = 0;
1309  return;
1310  }
1311  */
1312  if(type == DIM_DELETE)
1313  {
1314  find_release_request(conn_id, vtohl(dic_packet->service_id));
1315  return;
1316  }
1317  if(!(servp = find_service(dic_packet->service_name)))
1318  {
1319  release_conn(conn_id, 0, 0);
1320  return;
1321  }
1322  newp = (REQUEST *)/*my_*/malloc(sizeof(REQUEST));
1323  newp->service_ptr = servp;
1324  newp->service_id = vtohl(dic_packet->service_id);
1325  newp->type = dic_packet->type;
1326  newp->timeout = vtohl(dic_packet->timeout);
1327  newp->format = vtohl(dic_packet->format);
1328  newp->conn_id = conn_id;
1329  newp->first_time = 1;
1330  newp->delay_delete = 0;
1331  newp->to_delete = 0;
1332  newp->timr_ent = 0;
1333  newp->req_id = id_get((void *)newp, SRC_DIS);
1334  newp->reqpp = 0;
1335  if(type == ONCE_ONLY)
1336  {
1337  execute_service(newp->req_id);
1338  id_free(newp->req_id, SRC_DIS);
1339  free(newp);
1340  clip = create_client(conn_id, servp, &new_client);
1341  return;
1342  }
1343  if(type == COMMAND)
1344  {
1345  Curr_conn_id = conn_id;
1346  execute_command(servp, dic_packet);
1347  Curr_conn_id = 0;
1348  reqp = servp->request_head;
1349  while( (reqp = (REQUEST *) dll_get_next((DLL *)servp->request_head,
1350  (DLL *) reqp)) )
1351  {
1352  if(reqp->conn_id == conn_id)
1353  {
1354  id_free(newp->req_id, SRC_DIS);
1355  free(newp);
1356  found = 1;
1357  break;
1358  }
1359  }
1360  if(!found)
1361  dll_insert_queue( (DLL *) servp->request_head, (DLL *) newp );
1362  clip = create_client(conn_id, servp, &new_client);
1363  return;
1364  }
1365  dll_insert_queue( (DLL *) servp->request_head, (DLL *) newp );
1366  clip = create_client(conn_id, servp, &new_client);
1367  reqpp = (REQUEST_PTR *)malloc(sizeof(REQUEST_PTR));
1368  reqpp->reqp = newp;
1369  dll_insert_queue( (DLL *) clip->requestp_head, (DLL *) reqpp );
1370  newp->reqpp = reqpp;
1371  if((type != MONIT_ONLY) && (type != UPDATE))
1372  {
1373  execute_service(newp->req_id);
1374  }
1375  if((type != MONIT_ONLY) && (type != MONIT_FIRST))
1376  {
1377  if(newp->timeout != 0)
1378  {
1380  newp->timeout,
1382  newp->req_id );
1383  }
1384  }
1385  if(new_client)
1386  {
1387  Last_client = conn_id;
1388  dnsp = clip->dnsp;
1389  if(dnsp->dis_client_id)
1391  }
1392  }
1393 }
Definition: dns.c:26
int type
Definition: dim.h:234
#define MONIT_FIRST
Definition: dim_common.h:15
char service_name[MAX_NAME]
Definition: dim.h:232
char task[MAX_TASK_NAME]
Definition: dim.h:408
int service_id
Definition: dim.h:233
DllExp DIM_NOSHARE NET_CONNECTION * Net_conns
Definition: conn_handler.c:32
#define COMMAND
Definition: dim_common.h:10
int to_delete
Definition: dis.c:64
int service_id
Definition: dis.c:56
void dll_insert_queue(DLL *head, DLL *item)
Definition: dll.c:23
int execute_service(int req_id)
Definition: dis.c:1397
Definition: dis.c:98
int timeout
Definition: dim.h:235
int find_release_request(int conn_id, int service_id)
Definition: dis.c:2609
SERVICE * find_service(char *name)
Definition: dis.c:2429
void * malloc()
Definition: EventBuilder.cc:99
void dll_init(DLL *head)
Definition: dll.c:14
static int release_conn(int conn_id, int print_flg, int dns_flag)
Definition: dis.c:2684
char node[MAX_NODE_NAME]
Definition: dim.h:407
void execute_command(SERVICE *servp, DIC_PACKET *packet)
Definition: dis.c:1589
TIMR_ENT * timr_ent
Definition: dis.c:65
int format
Definition: dis.c:61
#define UPDATE
Definition: dim_common.h:13
static CLIENT * Client_head
Definition: dis.c:106
struct reqp_ent * reqpp
Definition: dis.c:66
Definition: dim.h:530
Definition: dis.c:69
int type
REQUEST * request_head
Definition: dis.c:86
DIS_DNS_CONN * dnsp
Definition: dis.c:103
static int Dis_timer_q
Definition: dis.c:143
REQUEST_PTR * requestp_head
Definition: dis.c:102
int dis_update_service(unsigned service_id)
Definition: dis.c:1685
static int Curr_conn_id
Definition: dis.c:123
struct serv * service_ptr
Definition: dis.c:59
int first_time
Definition: dis.c:62
static int Last_client
Definition: dis.c:149
int size
Definition: db_dim_server.c:17
void id_free(int id, SRC_TYPES type)
Definition: conn_handler.c:206
int format
Definition: dim.h:236
void free(void *mem)
TIMR_ENT * dtq_add_entry(int queue_id, int time, void(*user_routine)(), dim_long tag)
Definition: dtq.c:399
int type
Definition: dis.c:58
int delay_delete
Definition: dis.c:63
int timeout
Definition: dis.c:60
DLL * dll_get_next(DLL *head, DLL *item)
Definition: dll.c:66
Definition: dis.c:92
REQUEST * reqp
Definition: dis.c:95
int id_get(void *ptr, SRC_TYPES type)
Definition: conn_handler.c:152
void dim_print_date_time()
Definition: utilities.c:134
int req_id
Definition: dis.c:57
static int Debug_on
Definition: dis.c:156
#define ONCE_ONLY
Definition: dim_common.h:7
CLIENT * create_client(int conn_id, SERVICE *servp, int *new_client)
Definition: dis.c:2434
unsigned int dis_client_id
Definition: dis.c:48
int conn_id
Definition: dis.c:55
Definition: dis.c:52
#define DIM_DELETE
Definition: dim_common.h:11
#define MONIT_ONLY
Definition: dim_common.h:12

+ Here is the call graph for this function: