diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-07-21 16:12:28 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-10-04 14:49:57 -0700 |
commit | ac6d27348d4e01035183423a031445808c0f6b90 (patch) | |
tree | 8e3031b1175437c38b44b4a391a31c8b878db027 /host/lib/rfnoc | |
parent | 1bd3db57cab62517ecf282c670f2ccd35d1d303d (diff) | |
download | uhd-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')
-rw-r--r-- | host/lib/rfnoc/rx_stream_terminator.cpp | 6 | ||||
-rw-r--r-- | host/lib/rfnoc/rx_stream_terminator.hpp | 3 |
2 files changed, 9 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(); diff --git a/host/lib/rfnoc/rx_stream_terminator.hpp b/host/lib/rfnoc/rx_stream_terminator.hpp index 5159cd34a..fb205d00c 100644 --- a/host/lib/rfnoc/rx_stream_terminator.hpp +++ b/host/lib/rfnoc/rx_stream_terminator.hpp @@ -24,6 +24,7 @@ #include <uhd/rfnoc/scalar_node_ctrl.hpp> #include <uhd/rfnoc/terminator_node_ctrl.hpp> #include <uhd/rfnoc/block_ctrl_base.hpp> // For the block macros +#include <mutex> namespace uhd { namespace rfnoc { @@ -78,6 +79,8 @@ private: double _samp_rate; double _tick_rate; + std::mutex _overrun_handler_mutex; + }; /* class rx_stream_terminator */ }} /* namespace uhd::rfnoc */ |