aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/rfnoc/rx_stream_terminator.cpp
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2017-07-21 16:12:28 -0700
committerMartin Braun <martin.braun@ettus.com>2017-10-04 14:49:57 -0700
commitac6d27348d4e01035183423a031445808c0f6b90 (patch)
tree8e3031b1175437c38b44b4a391a31c8b878db027 /host/lib/rfnoc/rx_stream_terminator.cpp
parent1bd3db57cab62517ecf282c670f2ccd35d1d303d (diff)
downloaduhd-ac6d27348d4e01035183423a031445808c0f6b90.tar.gz
uhd-ac6d27348d4e01035183423a031445808c0f6b90.tar.bz2
uhd-ac6d27348d4e01035183423a031445808c0f6b90.zip
rfnoc: Fix potential double-overrun handling in rx stream terminator
It's feasible that error messages are sent out during overrun handling, which would cause a nested invocation of handle_overrun(). This adds a lock to prevent that.
Diffstat (limited to 'host/lib/rfnoc/rx_stream_terminator.cpp')
-rw-r--r--host/lib/rfnoc/rx_stream_terminator.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/host/lib/rfnoc/rx_stream_terminator.cpp b/host/lib/rfnoc/rx_stream_terminator.cpp
index e05d9cd49..7d38e2101 100644
--- a/host/lib/rfnoc/rx_stream_terminator.cpp
+++ b/host/lib/rfnoc/rx_stream_terminator.cpp
@@ -63,6 +63,12 @@ void rx_stream_terminator::set_rx_streamer(bool active, const size_t)
void rx_stream_terminator::handle_overrun(boost::weak_ptr<uhd::rx_streamer> streamer, const size_t)
{
+ std::unique_lock<std::mutex> l(_overrun_handler_mutex, std::defer_lock);
+ if (!l.try_lock()) {
+ // We're already handling overruns, so just stop right there
+ return;
+ }
+
std::vector<boost::shared_ptr<uhd::rfnoc::radio_ctrl_impl> > upstream_radio_nodes =
find_upstream_node<uhd::rfnoc::radio_ctrl_impl>();
const size_t n_radios = upstream_radio_nodes.size();