Changeset 723f1af
- Timestamp:
- 11/19/18 11:23:54 (2 years ago)
- Branches:
- develop
- Children:
- 1e6d795
- Parents:
- 89609d0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_linux_ring.c
r6f43f5c r723f1af 500 500 libtrace_packet_t *packet, 501 501 struct linux_per_stream_t *stream, 502 libtrace_message_queue_t *queue) { 502 libtrace_message_queue_t *queue, 503 uint8_t block) { 503 504 504 505 struct tpacket2_hdr *header; … … 512 513 /* Fetch the current frame */ 513 514 header = GET_CURRENT_BUFFER(stream); 514 assert((((unsigned long) header) & (pagesize - 1)) == 0); 515 if ((((unsigned long) header) & (pagesize - 1)) != 0) { 516 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, 517 "ring frame size is not a multiple of the page size"); 518 return -1; 519 } 515 520 516 521 /* TP_STATUS_USER means that we can use the frame. … … 519 524 */ 520 525 while (!(header->tp_status & TP_STATUS_USER) || 521 header->tp_status == TP_STATUS_LIBTRACE) { 522 if ((ret=is_halted(libtrace)) != -1) 523 return ret; 526 header->tp_status == TP_STATUS_LIBTRACE) { 527 if ((ret=is_halted(libtrace)) != -1) 528 return ret; 529 if (!block) { 530 return 0; 531 } 532 524 533 pollset[0].fd = stream->fd; 525 534 pollset[0].events = POLLIN; … … 610 619 libtrace_thread_t *t, 611 620 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; 621 size_t nb_packets) { 622 size_t i; 623 int ret; 624 625 for (i = 0; i < nb_packets; i++) { 626 ret = linuxring_read_stream(libtrace, packets[i], 627 t->format_data, &t->messages, i == 0 ? 1 : 0); 628 packets[i]->error = ret; 629 if (ret < 0) { 630 return ret; 631 } 632 633 if (ret == 0) { 634 if (is_halted(libtrace) == READ_EOF) { 635 return READ_EOF; 636 } 637 return i; 638 } 639 } 640 641 return nb_packets; 623 642 } 624 643 #endif … … 661 680 if (packet->buffer == NULL) 662 681 return; 663 assert(packet->trace); 682 if (!libtrace) { 683 return; 684 } 664 685 665 686 /* If we own the packet (i.e. it's not a copy), we need to free it */
Note: See TracChangeset
for help on using the changeset viewer.