FACT++  1.0
static int do_read ( int  conn_id)
static

Definition at line 705 of file tcpip.c.

References NET_CONNECTION::buffer, count, get_bytes_to_read(), NET_CONNECTION::last_used, Net_conns, NET_CONNECTION::read_rout, readsock, size, NET_CONNECTION::size, and time.

Referenced by io_sig_handler(), and tcpip_task().

706 {
707  /* There is 'data' pending, read it.
708  */
709  int len, totlen, size, count;
710  char *p;
711 
712  count = get_bytes_to_read(conn_id);
713  if(!count)
714  {
715 /*
716  dna_report_error(conn_id, -1,
717  "Connection closed by remote peer", DIM_ERROR, DIMTCPRDERR);
718  printf("conn_id %d\n", conn_id);
719 */
720  Net_conns[conn_id].read_rout( conn_id, -1, 0 );
721  return 0;
722  }
723 
724  size = Net_conns[conn_id].size;
725  p = Net_conns[conn_id].buffer;
726  totlen = 0;
727 /*
728  count = 1;
729 */
730  while( size > 0 && count > 0 )
731  {
732 /*
733  would this be better? not sure afterwards...
734  nbytes = (size < count) ? size : count;
735  if( (len = readsock(Net_conns[conn_id].channel, p, (size_t)nbytes, 0)) <= 0 )
736 */
737  if( (len = (int)readsock(Net_conns[conn_id].channel, p, (size_t)size, 0)) <= 0 )
738  { /* Connection closed by other side. */
739  Net_conns[conn_id].read_rout( conn_id, -1, 0 );
740  return 0;
741  }
742  else
743  {
744 
745  /*
746  printf("tcpip: read %d bytes:\n",len);
747  printf( "buffer[0]=%d\n", vtohl((int *)p[0]));
748  printf( "buffer[1]=%d\n", vtohl((int *)p[1]));
749  printf( "buffer[2]=%x\n", vtohl((int *)p[2]));
750  */
751  totlen += len;
752  size -= len;
753  p += len;
754  }
755  if(size)
756  count = get_bytes_to_read(conn_id);
757  }
758 
759  Net_conns[conn_id].last_used = time(NULL);
760  Net_conns[conn_id].read_rout( conn_id, 1, totlen );
761  return 1;
762 }
void(* read_rout)()
Definition: dim.h:400
char * buffer
Definition: dim.h:401
DllExp DIM_NOSHARE NET_CONNECTION * Net_conns
Definition: conn_handler.c:32
int size
Definition: dim.h:402
static int get_bytes_to_read(int conn_id)
Definition: tcpip.c:685
time_t last_used
Definition: dim.h:414
#define readsock(a, b, c, d)
Definition: tcpip.c:37
Warning because the service this data corrsponds to might have been last updated longer ago than Local time
Definition: smartfact.txt:92
int count
Definition: db_dim_server.c:18
int size
Definition: db_dim_server.c:17

+ Here is the call graph for this function:

+ Here is the caller graph for this function: