Changeset c4a4d3d
- Timestamp:
- 04/27/06 11:36:36 (15 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
- Children:
- 1f21c79
- Parents:
- 7af689a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_rt.c
rc3e5f30 rc4a4d3d 82 82 char *pkt_buffer; 83 83 char *buf_current; 84 int buf_ left;84 int buf_filled; 85 85 86 86 … … 197 197 RT_INFO->pkt_buffer = NULL; 198 198 RT_INFO->buf_current = NULL; 199 RT_INFO->buf_ left= 0;199 RT_INFO->buf_filled = 0; 200 200 201 201 if (strlen(uridata) == 0) { … … 269 269 static int rt_read(struct libtrace_t *libtrace, void **buffer, size_t len, int block) { 270 270 int numbytes; 271 271 rt_header_t *test_hdr; 272 272 273 assert(len <= RT_BUF_SIZE); 273 274 … … 275 276 RT_INFO->pkt_buffer = malloc(RT_BUF_SIZE); 276 277 RT_INFO->buf_current = RT_INFO->pkt_buffer; 277 RT_INFO->buf_ left= 0;278 RT_INFO->buf_filled = 0; 278 279 } 279 280 … … 288 289 289 290 290 if (len > RT_INFO->buf_ left) {291 if (len > RT_INFO->buf_filled) { 291 292 memcpy(RT_INFO->pkt_buffer, RT_INFO->buf_current, 292 RT_INFO->buf_ left);293 RT_INFO->buf_filled); 293 294 RT_INFO->buf_current = RT_INFO->pkt_buffer; 294 295 295 296 #ifndef MSG_NOSIGNAL 296 297 # define MSG_NOSIGNAL 0 297 298 #endif 298 while (len > RT_INFO->buf_ left) {299 while (len > RT_INFO->buf_filled) { 299 300 if ((numbytes = recv(RT_INFO->input_fd, 300 RT_INFO-> pkt_buffer+301 RT_INFO->buf_ left,302 RT_BUF_SIZE-RT_INFO->buf_ left,301 RT_INFO->buf_current + 302 RT_INFO->buf_filled, 303 RT_BUF_SIZE-RT_INFO->buf_filled, 303 304 MSG_NOSIGNAL|block)) <= 0) { 304 305 if (numbytes == 0) { … … 335 336 printf("\n"); 336 337 */ 337 RT_INFO->buf_ left+=numbytes;338 RT_INFO->buf_filled+=numbytes; 338 339 } 339 340 … … 341 342 *buffer = RT_INFO->buf_current; 342 343 RT_INFO->buf_current += len; 343 RT_INFO->buf_ left-= len;344 assert(RT_INFO->buf_ left>= 0);344 RT_INFO->buf_filled -= len; 345 assert(RT_INFO->buf_filled >= 0); 345 346 return len; 346 347 } … … 429 430 buf_ptr = ack_buffer; 430 431 431 432 432 while (to_write > 0) { 433 433 numbytes = send(RT_INFO->input_fd, buf_ptr, to_write, 0); … … 455 455 libtrace_packet_t *packet,int blocking) { 456 456 rt_header_t rt_hdr; 457 rt_header_t *pkt_hdr = &rt_hdr;457 static rt_header_t *pkt_hdr = 0; 458 458 int pkt_size = 0; 459 459 uint32_t seqno; 460 461 if (pkt_hdr == 0) 462 pkt_hdr = malloc(sizeof(rt_header_t)); 460 463 461 464 if (packet->buf_control == TRACE_CTRL_EXTERNAL || !packet->buffer) { … … 471 474 } 472 475 476 /* Need to salvage these in case the next rt_read overwrites the 477 * buffer they came from! */ 473 478 packet->type = pkt_hdr->type; 474 479 pkt_size = pkt_hdr->length; 475 480 packet->size = pkt_hdr->length; 481 seqno = pkt_hdr->sequence; 476 482 477 483 if (packet->type >= RT_DATA_SIMPLE) { … … 486 492 } 487 493 rt_set_payload(packet); 488 489 494 if (RT_INFO->reliable > 0) { 490 if (rt_send_ack(libtrace, pkt_hdr->sequence)495 if (rt_send_ack(libtrace, seqno) 491 496 == -1) 492 497 { … … 519 524 default: 520 525 printf("Bad rt type for client receipt: %d\n", 521 p kt_hdr->type);526 packet->type); 522 527 } 523 528 }
Note: See TracChangeset
for help on using the changeset viewer.