mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
fixed several bugs in the new state machine logic
This commit is contained in:
parent
96190a5822
commit
47bff0f9ba
8 changed files with 31 additions and 19 deletions
|
@ -147,7 +147,6 @@ int hook_cmp_priority(const void *a, const void *b)
|
|||
|
||||
int hook_parse_list(struct list *list, config_setting_t *cfg, struct path *o)
|
||||
{
|
||||
struct hook h;
|
||||
struct plugin *p;
|
||||
|
||||
int ret, priority = 10;
|
||||
|
@ -167,6 +166,8 @@ int hook_parse_list(struct list *list, config_setting_t *cfg, struct path *o)
|
|||
if (!config_setting_is_group(cfg_hook))
|
||||
cerror(cfg_hook, "The 'hooks' setting must be an array of strings.");
|
||||
|
||||
struct hook h = { .state = STATE_DESTROYED };
|
||||
|
||||
ret = hook_init(&h, &p->hook, o);
|
||||
if (ret)
|
||||
continue;
|
||||
|
|
|
@ -23,7 +23,7 @@ static int drop_read(struct hook *h, struct sample *smps[], size_t *cnt)
|
|||
if (h->prev) {
|
||||
dist = h->last->sequence - (int32_t) h->prev->sequence;
|
||||
if (dist <= 0) {
|
||||
warn("Dropped sample: dist = %d, i = %d", dist, i);
|
||||
warn("Dropped sample: sequence=%u, dist=%d, i=%d", h->last->sequence, dist, i);
|
||||
if (h->path && h->path->stats)
|
||||
stats_update(h->path->stats->delta, STATS_REORDERED, dist);
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ int node_start(struct node *n)
|
|||
|
||||
info("Starting node %s", node_name_long(n));
|
||||
{ INDENT
|
||||
ret = n->_vt->start ? n->_vt->start(n) : -1;
|
||||
ret = n->_vt->start ? n->_vt->start(n) : 0;
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ int node_stop(struct node *n)
|
|||
|
||||
info("Stopping node %s", node_name(n));
|
||||
{ INDENT
|
||||
ret = n->_vt->stop ? n->_vt->stop(n) : -1;
|
||||
ret = n->_vt->stop ? n->_vt->stop(n) : 0;
|
||||
}
|
||||
|
||||
if (ret == 0)
|
||||
|
|
|
@ -17,7 +17,7 @@ int node_type_start(struct node_type *vt, struct super_node *sn)
|
|||
{
|
||||
int ret;
|
||||
|
||||
if (vt->state != STATE_STARTED)
|
||||
if (vt->state != STATE_DESTROYED)
|
||||
return 0;
|
||||
|
||||
info("Initializing " YEL("%s") " node type which is used by %zu nodes", plugin_name(vt), list_length(&vt->instances));
|
||||
|
@ -40,7 +40,7 @@ int node_type_stop(struct node_type *vt)
|
|||
|
||||
info("De-initializing " YEL("%s") " node type", plugin_name(vt));
|
||||
{ INDENT
|
||||
ret = vt->deinit ? vt->deinit() : -1;
|
||||
ret = vt->deinit ? vt->deinit() : 0;
|
||||
}
|
||||
|
||||
if (ret == 0)
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
static struct plugin p;
|
||||
|
||||
/* Private static storage */
|
||||
struct list interfaces;
|
||||
struct list interfaces = { .state = STATE_DESTROYED };
|
||||
|
||||
int socket_init(struct super_node *sn)
|
||||
{
|
||||
|
@ -71,7 +71,7 @@ int socket_init(struct super_node *sn)
|
|||
}
|
||||
|
||||
/* If not found, create a new interface */
|
||||
struct interface j;
|
||||
struct interface j = { .sockets.state = STATE_DESTROYED };
|
||||
|
||||
ret = if_init(&j, link);
|
||||
if (ret)
|
||||
|
@ -94,7 +94,7 @@ found: list_push(&i->sockets, s);
|
|||
|
||||
int socket_deinit()
|
||||
{
|
||||
for (size_t j = 0; list_length(&interfaces); j++) {
|
||||
for (size_t j = 0; j < list_length(&interfaces); j++) {
|
||||
struct interface *i = list_at(&interfaces, j);
|
||||
|
||||
if_stop(i);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "nodes/websocket.h"
|
||||
|
||||
/* Private static storage */
|
||||
struct list connections; /**< List of active libwebsocket connections which receive samples from all nodes (catch all) */
|
||||
static struct list connections = { .state = STATE_DESTROYED }; /**< List of active libwebsocket connections which receive samples from all nodes (catch all) */
|
||||
|
||||
/* Forward declarations */
|
||||
static struct plugin p;
|
||||
|
|
|
@ -54,8 +54,9 @@ static void path_read(struct path *p)
|
|||
enqueue = hook_read_list(&p->hooks, smps, recv);
|
||||
if (enqueue != recv) {
|
||||
info("Hooks skipped %u out of %u samples for path %s", recv - enqueue, recv, path_name(p));
|
||||
|
||||
stats_update(p->stats->delta, STATS_SKIPPED, recv - enqueue);
|
||||
|
||||
if (p->stats)
|
||||
stats_update(p->stats->delta, STATS_SKIPPED, recv - enqueue);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < list_length(&p->destinations); i++) {
|
||||
|
@ -336,6 +337,9 @@ int path_start(struct path *p)
|
|||
int path_stop(struct path *p)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (p->state != STATE_STARTED)
|
||||
return 0;
|
||||
|
||||
info("Stopping path: %s", path_name(p));
|
||||
|
||||
|
|
|
@ -331,7 +331,7 @@ int super_node_start(struct super_node *sn)
|
|||
for (size_t i = 0; i < list_length(&sn->nodes); i++) { INDENT
|
||||
struct node *n = list_at(&sn->nodes, i);
|
||||
|
||||
node_type_start(n->_vt, sn->cli.argc, sn->cli.argv, config_root_setting(&sn->cfg));
|
||||
node_type_start(n->_vt, sn);
|
||||
}
|
||||
|
||||
info("Starting nodes");
|
||||
|
@ -364,28 +364,35 @@ int super_node_start(struct super_node *sn)
|
|||
|
||||
int super_node_stop(struct super_node *sn)
|
||||
{
|
||||
if (sn->state != STATE_STARTED)
|
||||
return 0;
|
||||
int ret;
|
||||
|
||||
info("Stopping paths");
|
||||
for (size_t i = 0; i < list_length(&sn->paths); i++) { INDENT
|
||||
struct path *p = list_at(&sn->paths, i);
|
||||
|
||||
path_stop(p);
|
||||
ret = path_stop(p);
|
||||
if (ret)
|
||||
error("Failed to stop path: %s", path_name(p));
|
||||
}
|
||||
|
||||
info("Stopping nodes");
|
||||
for (size_t i = 0; i < list_length(&sn->nodes); i++) { INDENT
|
||||
struct node *n = list_at(&sn->nodes, i);
|
||||
|
||||
node_stop(n);
|
||||
ret = node_stop(n);
|
||||
if (ret)
|
||||
error("Failed to stop node: %s", node_name(n));
|
||||
}
|
||||
|
||||
info("Stopping node types");
|
||||
for (size_t i = 0; i < list_length(&plugins); i++) { INDENT
|
||||
struct plugin *p = list_at(&plugins, i);
|
||||
if (p->type == PLUGIN_TYPE_NODE)
|
||||
node_type_stop(&p->node);
|
||||
|
||||
if (p->type == PLUGIN_TYPE_NODE) {
|
||||
ret = node_type_stop(&p->node);
|
||||
if (ret)
|
||||
error("Failed to stop node-type: %s", plugin_name(p));
|
||||
}
|
||||
}
|
||||
|
||||
web_stop(&sn->web);
|
||||
|
|
Loading…
Add table
Reference in a new issue