FACT++  1.0
int execute_service ( int  req_id)

Definition at line 1275 of file dis_old.c.

References serv::address, COMMAND, req_ent::conn_id, copy_swap_buffer_out(), Curr_conn_id, serv::def, req_ent::delay_delete, DIS_HEADER, DIS_STAMPED_HEADER, dna_write_nowait(), req_ent::first_time, req_ent::format, serv::format_data, Memory::free(), id_get_ptr(), Memory::malloc(), MAX_NAME, serv::quality, DIS_STAMPED_PACKET::quality, DIS_STAMPED_PACKET::reserved, req_ent::service_id, DIS_STAMPED_PACKET::service_id, req_ent::service_ptr, size, serv::size, DIS_STAMPED_PACKET::size, sprintf(), SRC_DIS, STAMPED, str, serv::tag, DIS_STAMPED_PACKET::time_stamp, req_ent::to_delete, req_ent::type, serv::type, serv::user_millisecs, serv::user_routine, and serv::user_secs.

Referenced by dis_insert_request(), dis_report_service(), and do_update_service().

1276 {
1277  int *buffp, size;
1278  register REQUEST *reqp;
1279  register SERVICE *servp;
1280  char str[80], def[MAX_NAME];
1281  register char *ptr;
1282  int last_conn_id;
1283  int *pkt_buffer, header_size, aux;
1284 #ifdef WIN32
1285  struct timeb timebuf;
1286 #else
1287  struct timeval tv;
1288  struct timezone *tz;
1289 #endif
1290  FORMAT_STR format_data_cp[MAX_NAME/4];
1291 
1292  reqp = (REQUEST *)id_get_ptr(req_id, SRC_DIS);
1293  if(!reqp)
1294  return(0);
1295  if(reqp->to_delete)
1296  return(0);
1297  reqp->delay_delete++;
1298  servp = reqp->service_ptr;
1299  last_conn_id = Curr_conn_id;
1300  Curr_conn_id = reqp->conn_id;
1301  ptr = servp->def;
1302  if(servp->type == COMMAND)
1303  {
1304  sprintf(str,"This is a COMMAND Service");
1305  buffp = (int *)str;
1306  size = 26;
1307  sprintf(def,"c:26");
1308  ptr = def;
1309  }
1310  else if( servp->user_routine != 0 )
1311  {
1312  (servp->user_routine)( &servp->tag, &buffp, &size,
1313  &reqp->first_time );
1314  reqp->first_time = 0;
1315 
1316  }
1317  else
1318  {
1319  buffp = servp->address;
1320  size = servp->size;
1321  }
1322  Curr_conn_id = last_conn_id;
1323 /* send even if no data but not if negative */
1324  if( size < 0)
1325  {
1326  reqp->delay_delete--;
1327  return(0);
1328  }
1329  if( DIS_STAMPED_HEADER + size > Dis_packet_size )
1330  {
1331  if( Dis_packet_size )
1332  free( Dis_packet );
1334  if(!Dis_packet)
1335  {
1336  reqp->delay_delete--;
1337  return(0);
1338  }
1340  }
1341  Dis_packet->service_id = htovl(reqp->service_id);
1342  if((reqp->type & 0xFF000) == STAMPED)
1343  {
1344  pkt_buffer = ((DIS_STAMPED_PACKET *)Dis_packet)->buffer;
1345  header_size = DIS_STAMPED_HEADER;
1346  if(!servp->user_secs)
1347  {
1348 #ifdef WIN32
1349  ftime(&timebuf);
1350  aux = timebuf.millitm;
1351  Dis_packet->time_stamp[0] = htovl(aux);
1352  Dis_packet->time_stamp[1] = htovl((int)timebuf.time);
1353 #else
1354  tz = 0;
1355  gettimeofday(&tv, tz);
1356  aux = tv.tv_usec / 1000;
1357  Dis_packet->time_stamp[0] = htovl(aux);
1358  Dis_packet->time_stamp[1] = htovl(tv.tv_sec);
1359 #endif
1360  }
1361  else
1362  {
1363  aux = /*0xc0de0000 |*/ servp->user_millisecs;
1364  Dis_packet->time_stamp[0] = htovl(aux);
1365  Dis_packet->time_stamp[1] = htovl(servp->user_secs);
1366  }
1367  Dis_packet->reserved[0] = htovl(0xc0dec0de);
1368  Dis_packet->quality = htovl(servp->quality);
1369  }
1370  else
1371  {
1372  pkt_buffer = ((DIS_PACKET *)Dis_packet)->buffer;
1373  header_size = DIS_HEADER;
1374  }
1375  memcpy(format_data_cp, servp->format_data, sizeof(format_data_cp));
1376  size = copy_swap_buffer_out(reqp->format, format_data_cp,
1377  pkt_buffer,
1378  buffp, size);
1379  Dis_packet->size = htovl(header_size + size);
1380  if( !dna_write_nowait(reqp->conn_id, Dis_packet, header_size + size) )
1381  {
1382  reqp->to_delete = 1;
1383  }
1384 /*
1385  else
1386  {
1387  if((reqp->type & 0xFFF) == MONITORED)
1388  {
1389  if(reqp->timr_ent)
1390  dtq_clear_entry(reqp->timr_ent);
1391  }
1392  }
1393 */
1394  reqp->delay_delete--;
1395  return(1);
1396 }
static int Dis_packet_size
Definition: dis_old.c:193
#define MAX_NAME
Definition: dim.h:182
int user_millisecs
Definition: dis.c:84
static DIS_STAMPED_PACKET * Dis_packet
Definition: dis_old.c:192
#define COMMAND
Definition: dim_common.h:10
char str[80]
Definition: test_client.c:7
void * id_get_ptr(int id, SRC_TYPES type)
Definition: conn_handler.c:184
int to_delete
Definition: dis.c:64
int service_id
Definition: dis.c:56
int time_stamp[2]
Definition: dim.h:254
int copy_swap_buffer_out(int format, FORMAT_STR *format_data, void *buff_out, void *buff_in, int size)
Definition: copy_swap.c:170
void * malloc()
Definition: EventBuilder.cc:99
int type
Definition: dis.c:74
#define DIS_STAMPED_HEADER
Definition: dim.h:260
#define STAMPED
Definition: dim_common.h:17
int reserved[3]
Definition: dim.h:256
dim_long tag
Definition: dis.c:80
int format
Definition: dis.c:61
FORMAT_STR format_data[MAX_NAME/4]
Definition: dis.c:76
static int Curr_conn_id
Definition: dis_old.c:123
Definition: dis.c:69
int user_secs
Definition: dis.c:83
void(* user_routine)()
Definition: dis.c:79
int dna_write_nowait(int conn_id, void *buffer, int size)
Definition: dna.c:412
struct serv * service_ptr
Definition: dis.c:59
int first_time
Definition: dis.c:62
int size
Definition: db_dim_server.c:17
int * address
Definition: dis.c:77
void free(void *mem)
int type
Definition: dis.c:58
int delay_delete
Definition: dis.c:63
char def[MAX_NAME]
Definition: dis.c:75
int size
Definition: dis.c:78
#define DIS_HEADER
Definition: dim.h:249
int conn_id
Definition: dis.c:55
Definition: dis.c:52
sprintf(name1,"NewService%d", i)
int quality
Definition: dis.c:82
int service_id
Definition: dim.h:253

+ Here is the call graph for this function:

+ Here is the caller graph for this function: