diff --git a/server/src/node.c b/server/src/node.c index cb16c041b..62480ca6e 100644 --- a/server/src/node.c +++ b/server/src/node.c @@ -70,20 +70,33 @@ int node_deinit() int node_start(struct node *n) { INDENT - info("Starting node '%s' of type '%s' (%s)", n->name, n->_vt->name, node_print(n)); + int ret; + info("Starting node '%s' of type '%s' (%s)", n->name, n->_vt->name, node_print(n)); { INDENT - return node_open(n); + ret = node_open(n); } + + if (ret == 0) + n->state = NODE_RUNNING; + + return ret; } int node_stop(struct node *n) { INDENT + int ret; + info("Stopping node '%s'", n->name); { INDENT - return node_close(n); + ret = node_close(n); } + + if (ret == 0) + n->state = NODE_STOPPED; + + return ret; } char * node_print(struct node *n) @@ -106,6 +119,7 @@ struct node * node_create(struct node_type *vt) list_push(&vt->instances, n); n->_vt = vt; + n->state = NODE_CREATED; return n; } diff --git a/server/src/path.c b/server/src/path.c index 7658e621c..78ab92e42 100644 --- a/server/src/path.c +++ b/server/src/path.c @@ -166,8 +166,10 @@ int path_start(struct path *p) pthread_create(&p->sent_tid, NULL, &path_run_async, p); } + + p->state = PATH_RUNNING; - return pthread_create(&p->recv_tid, NULL, &path_run, p); + return pthread_create(&p->recv_tid, NULL, &path_run, p); } int path_stop(struct path *p) @@ -183,6 +185,8 @@ int path_stop(struct path *p) close(p->tfd); } + + p->state = PATH_STOPPED; if (path_run_hook(p, HOOK_PATH_STOP)) return -1; @@ -215,6 +219,8 @@ struct path * path_create() if (h->type & HOOK_INTERNAL) list_push(&p->hooks, memdup(h, sizeof(*h))); } + + p->state = PATH_CREATED; return p; }