FACT++  1.0
void tcpip_task ( void *  dummy)

Definition at line 859 of file tcpip.c.

References count, data, DIM_IO_Done, DIM_IO_path, DIM_IO_valid, dim_usleep(), do_accept(), do_read(), fds_get_entry(), get_bytes_to_read(), list_to_fds(), MY_FD_CLR, MY_FD_ISSET, MY_FD_SET, MY_FD_ZERO, and Net_conns.

Referenced by dim_signal_cond(), and dim_tcpip_thread().

860 {
861  /* wait for an IO signal, find out what is happening and
862  * call the right routine to handle the situation.
863  */
864  fd_set rfds, *pfds;
865 #ifndef __linux__
866  fd_set efds;
867 #endif
868  int conn_id, ret, count;
869 #ifndef WIN32
870  int data;
871 #endif
872  if(dummy){}
873  while(1)
874  {
875  while(!DIM_IO_valid)
876  dim_usleep(1000);
877 
878  list_to_fds( &rfds );
879  MY_FD_ZERO(&efds);
880 #ifdef WIN32
881  pfds = &efds;
882 #else
883  pfds = &rfds;
884 #endif
885  MY_FD_SET( DIM_IO_path[0], pfds );
886 #ifdef __linux__
887  ret = poll(Pollfds, Pollfd_size, -1);
888 #else
889  ret = select(FD_SETSIZE, &rfds, NULL, &efds, NULL);
890 #endif
891  if(ret <= 0)
892  {
893  printf("poll returned %d, errno %d\n", ret, errno);
894  }
895  if(ret > 0)
896  {
897  if(MY_FD_ISSET(DIM_IO_path[0], pfds) )
898  {
899 #ifndef WIN32
900  read(DIM_IO_path[0], &data, 4);
901  DIM_IO_Done = 0;
902 #endif
903  MY_FD_CLR( (unsigned)DIM_IO_path[0], pfds );
904  }
905 /*
906  {
907  DISABLE_AST
908 */
909  conn_id = 0;
910  while( (ret = fds_get_entry( &rfds, &conn_id )) > 0 )
911  {
912  if( Net_conns[conn_id].reading )
913  {
914  count = 0;
915  do
916  {
917  DISABLE_AST
918  if(Net_conns[conn_id].channel)
919  {
920  do_read( conn_id );
921  count = get_bytes_to_read(conn_id);
922  }
923  else
924  {
925  count = 0;
926  }
927  ENABLE_AST
928  }while(count > 0 );
929  }
930  else
931  {
932  DISABLE_AST
933  do_accept( conn_id );
934  ENABLE_AST
935  }
936  MY_FD_CLR( (unsigned)Net_conns[conn_id].channel, &rfds );
937  }
938 /*
939  ENABLE_AST
940  }
941 */
942 #ifndef WIN32
943  return;
944 #endif
945  }
946  }
947 }
static int DIM_IO_valid
Definition: tcpip.c:101
DllExp DIM_NOSHARE NET_CONNECTION * Net_conns
Definition: conn_handler.c:32
void dim_usleep(int usecs)
Definition: dtq.c:293
static int get_bytes_to_read(int conn_id)
Definition: tcpip.c:685
#define MY_FD_SET(fd, set)
Definition: tcpip.c:78
static int DIM_IO_Done
Definition: tcpip.c:100
static int DIM_IO_path[2]
Definition: tcpip.c:99
#define MY_FD_ISSET(fd, set)
Definition: tcpip.c:80
#define MY_FD_ZERO(set)
Definition: tcpip.c:77
static int do_read(int conn_id)
Definition: tcpip.c:705
static int fds_get_entry(fd_set *fds, int *conn_id)
Definition: tcpip.c:570
int count
Definition: db_dim_server.c:18
float data[4 *1440]
#define MY_FD_CLR(fd, set)
Definition: tcpip.c:79
void do_accept(int conn_id)
Definition: tcpip.c:765
static int list_to_fds(fd_set *fds)
Definition: tcpip.c:535

+ Here is the call graph for this function:

+ Here is the caller graph for this function: