1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

improve error handling

This commit is contained in:
Steffen Vogel 2018-08-17 12:41:10 +02:00
parent c7a01a1da6
commit 569d50f012
3 changed files with 63 additions and 18 deletions

View file

@ -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;

View file

@ -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");

View file

@ -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;
}