From a2f10eed677861dfdb4a158c456a5e39302fe96e Mon Sep 17 00:00:00 2001 From: Steven Koo Date: Thu, 7 Jan 2021 13:11:02 -0600 Subject: uhd: Check for overflow after timeout buff read Error processing has been moved to another thread, so it's possible that consecutive recv calls may miss the signalling that an overflow occurred. We have no guarantee that the flag had been set by the time the second recv call to find the errors occurs. This adds another check for an overflow after calling _get_aligned_buffs with a min 1ms timeout. Hopefully this is long enough for the error to propogate, but it's not guaranteed. Signed-off-by: Steven Koo --- .../include/uhdlib/transport/rx_streamer_impl.hpp | 5 ---- .../uhdlib/transport/rx_streamer_zero_copy.hpp | 28 ++++++++++++---------- 2 files changed, 15 insertions(+), 18 deletions(-) (limited to 'host/lib/include') diff --git a/host/lib/include/uhdlib/transport/rx_streamer_impl.hpp b/host/lib/include/uhdlib/transport/rx_streamer_impl.hpp index f664eb68f..ce66d2ccb 100644 --- a/host/lib/include/uhdlib/transport/rx_streamer_impl.hpp +++ b/host/lib/include/uhdlib/transport/rx_streamer_impl.hpp @@ -136,11 +136,6 @@ public: return 0; } - if (nsamps_per_buff == 0) { - metadata.reset(); - return 0; - } - const int32_t timeout_ms = static_cast(timeout * 1000); detail::eov_data_wrapper eov_positions(metadata); diff --git a/host/lib/include/uhdlib/transport/rx_streamer_zero_copy.hpp b/host/lib/include/uhdlib/transport/rx_streamer_zero_copy.hpp index ca2eb3506..f30e3c843 100644 --- a/host/lib/include/uhdlib/transport/rx_streamer_zero_copy.hpp +++ b/host/lib/include/uhdlib/transport/rx_streamer_zero_copy.hpp @@ -213,21 +213,23 @@ public: auto result = _get_aligned_buffs(0); if (result == get_aligned_buffs_t::TIMEOUT) { - if (_stopped_due_to_overrun) { - // An overrun occurred and the user has read all the packets - // that were buffered prior to the overrun. Call the overrun - // handler and return overrun error. - _handle_overrun(); - std::tie(metadata.has_time_spec, metadata.time_spec) = - _last_read_time_info.get_next_packet_time(_samp_rate); - metadata.error_code = rx_metadata_t::ERROR_CODE_OVERFLOW; - _stopped_due_to_overrun = false; - return 0; - } else { + if (!_stopped_due_to_overrun) { // Packets were not available with zero timeout, wait for them // to arrive using the specified timeout. - result = _get_aligned_buffs(timeout_ms); - if (_stopped_due_to_late_cmd) { + result = _get_aligned_buffs(std::max(1,timeout_ms)); + } + if (result == get_aligned_buffs_t::TIMEOUT) { + if (_stopped_due_to_overrun) { + // An overrun occurred and the user has read all the packets + // that were buffered prior to the overrun. Call the overrun + // handler and return overrun error. + _handle_overrun(); + std::tie(metadata.has_time_spec, metadata.time_spec) = + _last_read_time_info.get_next_packet_time(_samp_rate); + metadata.error_code = rx_metadata_t::ERROR_CODE_OVERFLOW; + _stopped_due_to_overrun = false; + return 0; + } else if (_stopped_due_to_late_cmd) { metadata.has_time_spec = false; metadata.error_code = rx_metadata_t::ERROR_CODE_LATE_COMMAND; _stopped_due_to_late_cmd = false; -- cgit v1.2.3