aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorJoerg Hofrichter <joerg.hofrichter@ni.com>2019-12-05 16:34:57 +0100
committerMartin Braun <martin.braun@ettus.com>2020-01-22 12:25:05 -0800
commita09dad7fc6da3fe0c8b6e64b6187bb8b15191ccf (patch)
tree9baff73b4f87dc5a670b62821270ce796535cdba /host
parent6ee886cfe222aa9282d9f1aa74565a145d333fae (diff)
downloaduhd-a09dad7fc6da3fe0c8b6e64b6187bb8b15191ccf.tar.gz
uhd-a09dad7fc6da3fe0c8b6e64b6187bb8b15191ccf.tar.bz2
uhd-a09dad7fc6da3fe0c8b6e64b6187bb8b15191ccf.zip
transport: liberio: correctly release resources on destruction
Stop the streaming and free the allocated buffers on destruction of the liberio xport object. Note: There is a lingering resource leak in the kernel module, this patch merely orders the resource release correctly. Signed-off-by: Joerg Hofrichter <joerg.hofrichter@ni.com>
Diffstat (limited to 'host')
-rw-r--r--host/lib/transport/liberio_link.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/host/lib/transport/liberio_link.cpp b/host/lib/transport/liberio_link.cpp
index acc63ee37..ec8abbca8 100644
--- a/host/lib/transport/liberio_link.cpp
+++ b/host/lib/transport/liberio_link.cpp
@@ -75,9 +75,7 @@ liberio_link::liberio_link(
_tx_chan = ctx_holder.alloc_tx_chan(tx_path);
UHD_ASSERT_THROW(_tx_chan);
- /* Reset channel */
- liberio_chan_stop_streaming(_tx_chan);
- liberio_chan_request_buffers(_tx_chan, 0);
+ /* set the size, allocate */
UHD_ASSERT_THROW(!liberio_chan_set_fixed_size(_tx_chan, 0, params.send_frame_size));
UHD_ASSERT_THROW(!liberio_chan_request_buffers(_tx_chan, params.num_send_frames));
@@ -93,9 +91,7 @@ liberio_link::liberio_link(
_rx_chan = ctx_holder.alloc_rx_chan(rx_path);
UHD_ASSERT_THROW(_rx_chan);
- /* stop the channel, free the buffers, set the size, allocate */
- liberio_chan_stop_streaming(_rx_chan);
- liberio_chan_request_buffers(_rx_chan, 0);
+ /* set the size, allocate */
UHD_ASSERT_THROW(!liberio_chan_set_fixed_size(_rx_chan, 0, params.recv_frame_size));
UHD_ASSERT_THROW(!liberio_chan_request_buffers(_rx_chan, params.num_recv_frames));
/* TODO: Check params in factory and adjust them there instead of throwing exception
@@ -134,7 +130,13 @@ liberio_link::liberio_link(
liberio_link::~liberio_link()
{
+ /* stop the channel, free the buffers */
+ liberio_chan_stop_streaming(_tx_chan);
+ liberio_chan_request_buffers(_tx_chan, 0);
liberio_chan_put(_tx_chan);
+
+ liberio_chan_stop_streaming(_rx_chan);
+ liberio_chan_request_buffers(_rx_chan, 0);
liberio_chan_put(_rx_chan);
}