Changeset f96ad61
- Timestamp:
- 10/24/18 15:20:19 (2 years ago)
- Branches:
- ringperformance
- Children:
- 84dbd79
- Parents:
- 928db3d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_linux_ring.c
r928db3d rf96ad61 320 320 #ifdef HAVE_PACKET_FANOUT 321 321 static int linuxring_pstart_input(libtrace_t *libtrace) { 322 /* Only because our pread is hard-coded to only do one323 * packet at a time anyway */324 libtrace->config.burst_size = 1;325 322 return linuxcommon_pstart_input(libtrace, linuxring_start_input_stream); 326 323 } … … 465 462 } 466 463 467 static in t linuxring_prepare_packet(libtrace_t *libtrace UNUSED,464 static inline int _linuxring_prepare_packet( 468 465 libtrace_packet_t *packet, void *buffer, 469 466 libtrace_rt_types_t rt_type, uint32_t flags) … … 491 488 } 492 489 490 static inline int linuxring_prepare_packet(libtrace_t *libtrace UNUSED, 491 libtrace_packet_t *packet, void *buffer, 492 libtrace_rt_types_t rt_type, uint32_t flags) 493 { 494 return _linuxring_prepare_packet(packet, buffer, rt_type, flags); 495 } 493 496 #ifdef HAVE_NETPACKET_PACKET_H 494 497 #define LIBTRACE_MIN(a,b) ((a)<(b) ? (a) : (b)) … … 500 503 libtrace_packet_t *packet, 501 504 struct linux_per_stream_t *stream, 502 libtrace_message_queue_t *queue) { 505 libtrace_message_queue_t *queue, 506 int block) { 503 507 504 508 struct tpacket2_hdr *header; … … 518 522 * ready for consumption. 519 523 */ 524 520 525 while (!(header->tp_status & TP_STATUS_USER) || 521 header->tp_status == TP_STATUS_LIBTRACE) { 526 header->tp_status == TP_STATUS_LIBTRACE) { 527 if (!block) { 528 return 0; 529 } 530 522 531 if ((ret=is_halted(libtrace)) != -1) 523 532 return ret; … … 594 603 /* We just need to get prepare_packet to set all our packet pointers 595 604 * appropriately */ 596 if ( linuxring_prepare_packet(libtrace,packet, packet->buffer,605 if (_linuxring_prepare_packet(packet, packet->buffer, 597 606 packet->type, 0)) 598 607 return -1; … … 603 612 604 613 static int linuxring_read_packet(libtrace_t *libtrace, libtrace_packet_t *packet) { 605 return linuxring_read_stream(libtrace, packet, FORMAT_DATA_FIRST, NULL); 614 return linuxring_read_stream(libtrace, packet, FORMAT_DATA_FIRST, 615 NULL, 1); 606 616 } 607 617 … … 610 620 libtrace_thread_t *t, 611 621 libtrace_packet_t *packets[], 612 UNUSED size_t nb_packets) { 613 /* For now just read one packet */ 614 /* If we change this to actually read nb_packets, make sure 615 * we remove the burst_size override in linuxring_pstart_input() 616 */ 617 packets[0]->error = linuxring_read_stream(libtrace, packets[0], 618 t->format_data, &t->messages); 619 if (packets[0]->error >= 1) 620 return 1; 621 else 622 return packets[0]->error; 622 size_t nb_packets) { 623 size_t i; 624 625 for (i = 0; i < nb_packets; i++) { 626 packets[i]->error = linuxring_read_stream(libtrace, packets[i], 627 t->format_data, &t->messages, i == 0 ? 1 : 0); 628 629 if (packets[i]->error < 0) { 630 return packets[i]->error; 631 } 632 633 if (packets[i]->error == 0) { 634 return i; 635 } 636 } 637 638 return nb_packets; 623 639 } 624 640 #endif
Note: See TracChangeset
for help on using the changeset viewer.