Skip to content

Commit 0790a2a

Browse files
committed
fix: data reception in packet mode
make sure to receive all packets; we might lose IRQs if not all incoming packets are processed
1 parent 07c857e commit 0790a2a

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

src/DataHandlerAbstract.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,22 @@ void DataHandlerAbstract::_handle_input(const boost::system::error_code& ec) {
6969
}
7070

7171
if (dma_stat.ioc_irq) {
72-
auto full_bufs = _receive_packets ? _desc.get_next_packet() : _desc.get_full_buffers();
73-
if (full_bufs.empty()) {
74-
BOOST_LOG_SEV(_lg, bls::trace) << "spurious event, got no data";
75-
} else {
76-
auto bytes = _desc.read_buffers(full_bufs);
77-
process_data(std::move(bytes));
72+
bool spurious_event = true;
73+
// Receive data until there's no more incoming packets or full buffers
74+
// (esp. important in packet mode where get_next_packet() will only
75+
// return *one* packet, regardless of more incoming data in the pipeline)
76+
while (true) {
77+
auto full_bufs = _receive_packets ? _desc.get_next_packet() : _desc.get_full_buffers();
78+
if (full_bufs.empty()) {
79+
if (spurious_event) {
80+
BOOST_LOG_SEV(_lg, bls::trace) << "spurious event, got no data";
81+
}
82+
break;
83+
} else {
84+
auto bytes = _desc.read_buffers(full_bufs);
85+
process_data(std::move(bytes));
86+
spurious_event = false;
87+
}
7888
}
7989
}
8090

0 commit comments

Comments
 (0)