diff --git a/lib/super_node.c b/lib/super_node.c index 5c9fb37ab..b9f17516f 100644 --- a/lib/super_node.c +++ b/lib/super_node.c @@ -45,20 +45,36 @@ int super_node_init(struct super_node *sn) { + int ret; + assert(sn->state == STATE_DESTROYED); - log_init(&sn->log, V, LOG_ALL); + ret = log_init(&sn->log, V, LOG_ALL); + if (ret) + return ret; + #ifdef WITH_API - memory_init(0); - api_init(&sn->api, sn); + ret = api_init(&sn->api, sn); + if (ret) + return ret; #endif /* WITH_API */ #ifdef WITH_WEB - web_init(&sn->web, &sn->api); + ret = web_init(&sn->web, &sn->api); + if (ret) + return ret; #endif /* WITH_WEB */ - list_init(&sn->nodes); - list_init(&sn->paths); - list_init(&sn->plugins); + ret = list_init(&sn->nodes); + if (ret) + return ret; + + ret = list_init(&sn->paths); + if (ret) + return ret; + + ret = list_init(&sn->plugins); + if (ret) + return ret; /* Default values */ sn->affinity = 0; diff --git a/src/villas-test-cmp.cpp b/src/villas-test-cmp.cpp index 1ca3eddeb..5915ffb76 100644 --- a/src/villas-test-cmp.cpp +++ b/src/villas-test-cmp.cpp @@ -120,7 +120,10 @@ check: if (optarg == endptr) int n = argc - optind; /* The number of files which we compare */ struct side s[n]; - memory_init(0); + ret = memory_init(0); + if (ret) + error("Failed to initialize memory system"); + ret = pool_init(&pool, n, SAMPLE_LENGTH(DEFAULT_SAMPLE_LENGTH), &memory_heap); if (ret) error("Failed to initialize pool"); diff --git a/src/villas-test-rtt.cpp b/src/villas-test-rtt.cpp index 660d8bef8..24dec6b38 100644 --- a/src/villas-test-rtt.cpp +++ b/src/villas-test-rtt.cpp @@ -84,6 +84,8 @@ void usage() int main(int argc, char *argv[]) { + int ret; + /* Parse Arguments */ char c, *endptr; while ((c = getopt (argc, argv, "w:h:r:f:c:b:V")) != -1) { @@ -123,16 +125,33 @@ check: if (optarg == endptr) char *configfile = argv[optind]; char *nodestr = argv[optind + 1]; - log_init(&sn.log, V, LOG_ALL); + ret = signals_init(quit); + if (ret) + error("Failed to initialize signals"); - super_node_init(&sn); - super_node_parse_uri(&sn, configfile); + ret = log_init(&sn.log, V, LOG_ALL); + if (ret) + return ret; - log_open(&sn.log); + ret = super_node_init(&sn); + if (ret) + error("Failed to initialize super-node"); - signals_init(quit); - rt_init(sn.priority, sn.affinity); - memory_init(sn.hugepages); + ret = super_node_parse_uri(&sn, configfile); + if (ret) + error("Failed to parse configuration"); + + ret = log_open(&sn.log); + if (ret) + error("Failed to open log file"); + + ret = rt_init(sn.priority, sn.affinity); + if (ret) + return ret; + + ret = memory_init(sn.hugepages); + if (ret) + error("Failed to stop node-type %s: reason=%d", node_type_name(node->_vt), ret); node = (struct node *) list_lookup(&sn.nodes, nodestr); if (!node) @@ -152,10 +171,17 @@ check: if (optarg == endptr) test_rtt(); - node_stop(node); - node_type_stop(node->_vt); + ret = node_stop(node); + if (ret) + error("Failed to stop node %s: reason=%d", node_name(node), ret); - super_node_destroy(&sn); + ret = node_type_stop(node->_vt); + if (ret) + error("Failed to stop node-type %s: reason=%d", node_type_name(node->_vt), ret); + + ret = super_node_destroy(&sn); + if (ret) + error("Failed to destroy super-node"); return 0; }