aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2019-09-11 19:47:21 -0700
committerMartin Braun <martin.braun@ettus.com>2019-11-26 11:49:44 -0800
commit2d40c33b15ee91fdf5f0f7ca6987fe7dbf18205a (patch)
treea8e132fa124c2fe163eec5d7adfaa8d8e698d446
parentb59b9ed3a7f62d2a6d7933a18b11b0b29c33c689 (diff)
downloaduhd-2d40c33b15ee91fdf5f0f7ca6987fe7dbf18205a.tar.gz
uhd-2d40c33b15ee91fdf5f0f7ca6987fe7dbf18205a.tar.bz2
uhd-2d40c33b15ee91fdf5f0f7ca6987fe7dbf18205a.zip
rfnoc: rfnoc_graph: Safely deinit full graph on any kind of init error
In the rfnoc_graph, we init blocks, GSM, motherboard controllers, and other things. Since any of these can potentially throw exceptions, we make sure to deinit those components that have already initialized properly before exiting.
-rw-r--r--host/lib/rfnoc/rfnoc_graph.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/host/lib/rfnoc/rfnoc_graph.cpp b/host/lib/rfnoc/rfnoc_graph.cpp
index 60afbdad5..a6ec59d01 100644
--- a/host/lib/rfnoc/rfnoc_graph.cpp
+++ b/host/lib/rfnoc/rfnoc_graph.cpp
@@ -54,24 +54,24 @@ public:
// Now initialize all subsystems:
_init_mb_controllers();
_init_gsm(); // Graph Stream Manager
- for (size_t mb_idx = 0; mb_idx < _num_mboards; ++mb_idx) {
- try {
- // If anything fails here, we immediately deinit all the other
- // blocks to avoid any more fallout, then safely bring down the
- // device.
+ try {
+ // If anything fails here, we immediately deinit all the other
+ // blocks to avoid any more fallout, then safely bring down the
+ // device.
+ for (size_t mb_idx = 0; mb_idx < _num_mboards; ++mb_idx) {
_init_blocks(mb_idx, dev_addr);
- } catch (...) {
- _block_registry->shutdown();
- throw;
}
+ UHD_LOG_TRACE(LOG_ID, "Initializing properties on all blocks...");
+ _block_registry->init_props();
+ _init_sep_map();
+ _init_static_connections();
+ _init_mbc();
+ // Start with time set to zero, but don't complain if sync fails
+ rfnoc_graph_impl::synchronize_devices(uhd::time_spec_t(0.0), true);
+ } catch (...) {
+ _block_registry->shutdown();
+ throw;
}
- UHD_LOG_TRACE(LOG_ID, "Initializing properties on all blocks...");
- _block_registry->init_props();
- _init_sep_map();
- _init_static_connections();
- _init_mbc();
- // Start with time set to zero, but don't complain if sync fails
- rfnoc_graph_impl::synchronize_devices(uhd::time_spec_t(0.0), true);
} catch (const std::exception& ex) {
UHD_LOG_ERROR(LOG_ID, "Caught exception while initializing graph: " << ex.what());
throw uhd::runtime_error("Failure to create rfnoc_graph.");