Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion platform/linux-generic/pktio/pcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,15 @@ static int pcapif_recv_pkt(pktio_entry_t *pktio_entry, int index ODP_UNUSED,
if (ret == -2 && _pcapif_reopen(pcap) == 0)
continue;

if (ret != 1)
if (ret != 1) {
/* More packets may be appended to the input file after EOF has
* been seen (e.g. when the file is the output of another pcap
* pktio). Clear the sticky EOF indicator of the underlying stream
* so that subsequent receive calls can see the appended packets. */
if (ret == -2 && pcap->rx)
clearerr(pcap_file(pcap->rx));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matter of taste, but alternatively, this could be done inside _pcapif_reopen(), less re-checks.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think that would improve the code since then _pcapif_reopen() would not be only about reopening (which is done only if requested through the loops parameter, and is skipped entirely in process mode). The clearerr() is for the opposite case where we do not want to reopen on EOF but want to retry in case more packets get appended to the file.

break;
}

pkt_len = hdr->caplen;

Expand Down
Loading
Loading