diff --git a/lib/node.c b/lib/node.c index de9e1a5e2..c39827f12 100644 --- a/lib/node.c +++ b/lib/node.c @@ -30,14 +30,15 @@ int node_write(struct node *n, struct msg *p, int ps, int f, int c) return n->_vt->write ? n->_vt->write(n, p, ps, f, c) : -1; } -int node_init(int argc, char *argv[], struct settings *set) -{ INDENT +int node_init(int argc, char *argv[], config_setting_t *cfg) +{ list_foreach(const struct node_type *vt, &node_types) { if (list_length(&vt->instances) > 0) { info("Initializing " YEL("%s") " node type", vt->name); - if (vt->init) - vt->init(argc, argv, set); + if (vt->init) { INDENT + vt->init(argc, argv, cfg); + } } else warn("No node is using the " YEL("%s") " node type. Skipping...", vt->name); @@ -47,14 +48,15 @@ int node_init(int argc, char *argv[], struct settings *set) } int node_deinit() -{ INDENT +{ /* De-initialize node types */ list_foreach(const struct node_type *vt, &node_types) { if (list_length(&vt->instances) > 0) { info("De-initializing " YEL("%s") " node type", vt->name); - if (vt->deinit) + if (vt->deinit) { INDENT vt->deinit(); + } } } @@ -62,7 +64,7 @@ int node_deinit() } int node_start(struct node *n) -{ INDENT +{ int ret; info("Starting node %s", node_name_long(n)); @@ -77,7 +79,7 @@ int node_start(struct node *n) } int node_stop(struct node *n) -{ INDENT +{ int ret; if (n->state != NODE_RUNNING) @@ -106,7 +108,7 @@ const char * node_name(struct node *n) const char * node_name_long(struct node *n) { if (!n->_name_long) - n->_name_long = n->_vt->print ? n->_vt->print(n) : ""; + n->_name_long = n->_vt->print ? n->_vt->print(n) : node_name(n); return n->_name_long; } diff --git a/lib/opal.c b/lib/opal.c index 59af0ba5b..e7c640bd0 100644 --- a/lib/opal.c +++ b/lib/opal.c @@ -17,8 +17,8 @@ /** Global OPAL specific settings */ static struct opal_global *og = NULL; -int opal_init(int argc, char *argv[], struct settings *set) -{ INDENT +int opal_init(int argc, char *argv[], config_setting_t *cfg) +{ int err; if (argc != 4) @@ -74,7 +74,7 @@ int opal_init(int argc, char *argv[], struct settings *set) } int opal_deinit() -{ INDENT +{ int err; if (!og) @@ -102,7 +102,7 @@ int opal_deinit() } int opal_print_global(struct opal_global *g) -{ INDENT +{ debug(2, "Controller ID: %u", og->params.controllerID); char *sbuf = alloc(og->send_icons * 5); diff --git a/lib/socket.c b/lib/socket.c index d1ed2fe06..041a240b1 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -38,8 +38,8 @@ extern struct list interfaces; /* Forward declartions */ static struct node_type vt; -int socket_init(int argc, char * argv[], struct settings *set) -{ INDENT +int socket_init(int argc, char * argv[], config_setting_t *cfg) +{ if (check_root()) error("The 'socket' node-type requires superuser privileges!"); @@ -78,7 +78,7 @@ int socket_init(int argc, char * argv[], struct settings *set) } int socket_deinit() -{ INDENT +{ list_foreach(struct interface *i, &interfaces) if_stop(i); diff --git a/src/path.c b/src/path.c index 5580266ad..c26f41a65 100644 --- a/src/path.c +++ b/src/path.c @@ -138,7 +138,7 @@ static void * path_run(void *arg) } int path_start(struct path *p) -{ INDENT +{ info("Starting path: %s (poolsize=%u, msgsize=%u, #hooks=%zu, rate=%.1f)", path_name(p), p->poolsize, p->msgsize, list_length(&p->hooks), p->rate); @@ -173,7 +173,7 @@ int path_start(struct path *p) } int path_stop(struct path *p) -{ INDENT +{ info("Stopping path: %s", path_name(p)); pthread_cancel(p->recv_tid); diff --git a/src/server.c b/src/server.c index a695c6b7b..0f7cb428a 100644 --- a/src/server.c +++ b/src/server.c @@ -33,15 +33,19 @@ static config_t config; /**< libconfig handle */ static void quit() { info("Stopping paths"); - list_foreach(struct path *p, &paths) + list_foreach(struct path *p, &paths) { INDENT path_stop(p); + } info("Stopping nodes"); - list_foreach(struct node *n, &nodes) + list_foreach(struct node *n, &nodes) { INDENT node_stop(n); + } info("De-initializing node types"); - node_deinit(); + { INDENT + node_deinit(); + } /* Freeing dynamically allocated memory */ list_destroy(&paths); @@ -54,7 +58,7 @@ static void quit() } static void realtime_init() -{ INDENT +{ if (check_kernel_cmdline()) warn("You should reserve some cores for the server (see 'isolcpus')"); if (check_kernel_rt()) @@ -143,20 +147,28 @@ int main(int argc, char *argv[]) list_init(&paths, (dtor_cb_t) path_destroy); info("Initialize real-time system"); - realtime_init(); + { INDENT + realtime_init(); + } info("Initialize signals"); - signals_init(); + { INDENT + signals_init(); + } info("Parsing configuration"); - config_init(&config); - config_parse(configfile, &config, &settings, &nodes, &paths); + { INDENT + config_init(&config); + config_parse(configfile, &config, &settings, &nodes, &paths); + } info("Initialize node types"); + { INDENT node_init(argc, argv, config_root_setting(&config)); + } info("Starting nodes"); - list_foreach(struct node *n, &nodes) { + list_foreach(struct node *n, &nodes) { INDENT int used_by_path(struct path *p, struct node *n) { return (p->in == n) || list_contains(&p->destinations, n); } @@ -165,11 +177,11 @@ int main(int argc, char *argv[]) if (refs > 0) node_start(n); else - warn("Node %s is unused. Skipping...", node_name(n)); + warn("No path is using the node %s. Skipping...", node_name(n)); } info("Starting paths"); - list_foreach(struct path *p, &paths) { + list_foreach(struct path *p, &paths) { INDENT if (p->enabled) path_start(p); else