FACT++  1.0
static void ast_read_h ( int  conn_id,
int  status,
int  size 
)
static

Definition at line 134 of file dna.c.

References buff, DNA_CONNECTION::buffer, DNA_CONNECTION::curr_buffer, DNA_CONNECTION::curr_size, DIM_ERROR, DIMTCPRDERR, Dna_conns, dna_report_error(), dna_start_read(), is_header(), RD_DATA, RD_HDR, DNA_CONNECTION::read_ast, read_data(), READ_HEADER_SIZE, size, STA_DISC, DNA_CONNECTION::state, tcpip_failure(), Tcpip_max_io_data_read, and tcpip_start_read().

135 {
136  register DNA_CONNECTION *dna_connp = &Dna_conns[conn_id];
137  int tcpip_code;
138  register int read_size, next_size;
139  register char *buff;
140  int max_io_data;
141 
142  if(!dna_connp->buffer) /* The connection has already been closed */
143  {
144  return;
145  }
146  if(status == 1)
147  {
148  next_size = dna_connp->curr_size;
149  buff = (char *) dna_connp->curr_buffer;
150  if(size < next_size)
151  {
152 /*
153  Prev_conn_id = conn_id;
154  Prev_packet[0] = ((int *)dna_connp->curr_buffer)[0];
155  Prev_packet[1] = ((int *)dna_connp->curr_buffer)[1];
156  Prev_packet[2] = ((int *)dna_connp->curr_buffer)[2];
157  Prev_buffer[0] = dna_connp->buffer[0];
158  Prev_buffer[1] = dna_connp->buffer[1];
159  Prev_buffer[2] = dna_connp->buffer[2];
160 */
161  max_io_data = Tcpip_max_io_data_read;
162  read_size = ((next_size - size) > max_io_data) ?
163  max_io_data : next_size - size;
164  dna_connp->curr_size -= size;
165  dna_connp->curr_buffer += size;
166  tcpip_code = tcpip_start_read(conn_id, buff + size,
167  read_size, ast_read_h);
168  if(tcpip_failure(tcpip_code))
169  {
170 #ifndef WIN32
171  if(errno == ENOTSOCK)
172  {
173  if(dna_connp->read_ast)
174  dna_connp->read_ast(conn_id, NULL, 0, STA_DISC);
175  }
176  else
177 #endif
178  {
179  dna_report_error(conn_id, tcpip_code,
180  "Reading from", DIM_ERROR, DIMTCPRDERR);
181  }
182  }
183  return;
184  }
185  switch(dna_connp->state)
186  {
187  case RD_HDR :
188  if(is_header(conn_id))
189  {
190  if( dna_connp->state == RD_DATA )
191  {
192  next_size = vtohl(dna_connp->buffer[1]);
193  dna_start_read(conn_id, next_size);
194  }
195  else
196  {
197  dna_connp->state = RD_HDR;
199  }
200  }
201  break;
202  case RD_DATA :
203  read_data(conn_id);
204  dna_connp->state = RD_HDR;
206  break;
207  default:
208  break;
209  }
210 /*
211  if(dna_connp->buffer)
212  {
213  Prev_conn_id = conn_id;
214  Prev_packet[0] = ((int *)dna_connp->curr_buffer)[0];
215  Prev_packet[1] = ((int *)dna_connp->curr_buffer)[1];
216  Prev_packet[2] = ((int *)dna_connp->curr_buffer)[2];
217  Prev_buffer[0] = dna_connp->buffer[0];
218  Prev_buffer[1] = dna_connp->buffer[1];
219  Prev_buffer[2] = dna_connp->buffer[2];
220  }
221 */
222  }
223  else
224  {
225  /*
226  printf("Connection lost. Signal upper layer\n");
227  */
228  if(dna_connp->read_ast)
229  dna_connp->read_ast(conn_id, NULL, 0, STA_DISC);
230  }
231 }
static void ast_read_h(int conn_id, int status, int size)
Definition: dna.c:134
int Tcpip_max_io_data_read
Definition: tcpip.c:111
#define READ_HEADER_SIZE
Definition: dna.c:21
#define STA_DISC
Definition: dim.h:197
#define DIMTCPRDERR
Definition: dim_common.h:293
Definition: dim.h:190
static void read_data(int conn_id)
Definition: dna.c:114
CONN_STATE state
Definition: dim.h:390
int curr_size
Definition: dim.h:387
int tcpip_start_read(int conn_id, char *buffer, int size, void(*ast_routine)())
Definition: tcpip.c:949
void dna_report_error(int conn_id, int code, char *routine_name, int severity, int errcode)
Definition: dna.c:903
int size
Definition: db_dim_server.c:17
static int is_header(int conn_id)
Definition: dna.c:62
DllExp DIM_NOSHARE DNA_CONNECTION * Dna_conns
Definition: conn_handler.c:31
int buff[BUFFSIZE]
Definition: db_dim_client.c:15
int * buffer
Definition: dim.h:384
Definition: dim.h:190
int dna_start_read(int conn_id, int size)
Definition: dna.c:234
int tcpip_failure(int code)
Definition: tcpip.c:1540
void(* read_ast)()
Definition: dim.h:382
char * curr_buffer
Definition: dim.h:386

+ Here is the call graph for this function: