aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authorSteven Koo <steven.koo@ni.com>2021-01-07 13:11:02 -0600
committerAaron Rossetto <aaron.rossetto@ni.com>2021-01-21 12:47:17 -0600
commita2f10eed677861dfdb4a158c456a5e39302fe96e (patch)
treec1b1623c2247af48a9ca9fe9675c8736dd6e1d1e /host/lib
parent92cb632ce1e443b1b3cffdc314cab57943b39f8c (diff)
downloaduhd-a2f10eed677861dfdb4a158c456a5e39302fe96e.tar.gz
uhd-a2f10eed677861dfdb4a158c456a5e39302fe96e.tar.bz2
uhd-a2f10eed677861dfdb4a158c456a5e39302fe96e.zip
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 <steven.koo@ni.com>
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/include/uhdlib/transport/rx_streamer_impl.hpp5
-rw-r--r--host/lib/include/uhdlib/transport/rx_streamer_zero_copy.hpp28
-rw-r--r--host/lib/transport/super_recv_packet_handler.hpp6
3 files changed, 15 insertions, 24 deletions
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<int32_t>(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;
diff --git a/host/lib/transport/super_recv_packet_handler.hpp b/host/lib/transport/super_recv_packet_handler.hpp
index c6947ba26..f428f01f1 100644
--- a/host/lib/transport/super_recv_packet_handler.hpp
+++ b/host/lib/transport/super_recv_packet_handler.hpp
@@ -238,12 +238,6 @@ public:
return 0;
}
- // Just return if no samples requested
- if (nsamps_per_buff == 0) {
- metadata.reset();
- return 0;
- }
-
size_t accum_num_samps =
recv_one_packet(buffs, nsamps_per_buff, metadata, timeout);