From fe39f6c7a89f2625b095f63acaa1fc558368b774 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 9 Feb 2016 05:35:23 +0100 Subject: [PATCH] added 2 new node states --- include/node.h | 2 ++ lib/node.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/include/node.h b/include/node.h index f2176877b..19d2656f8 100644 --- a/include/node.h +++ b/include/node.h @@ -168,7 +168,9 @@ struct node enum node_state { NODE_INVALID, /**< This node object is not in a valid state. */ NODE_CREATED, /**< This node has been parsed from the configuration. */ + NODE_STARTING, /**< This node is currently being started. */ NODE_RUNNING, /**< This node has been started by calling node_open() */ + NODE_STOPPING, /**< This node is currently shutting down. */ NODE_STOPPED /**< Node was running, but has been stopped by calling node_close() */ } state; /**< Node state */ diff --git a/lib/node.c b/lib/node.c index ecc257e97..119ac2ad6 100644 --- a/lib/node.c +++ b/lib/node.c @@ -86,6 +86,11 @@ int node_deinit(struct node_type *vt) int node_start(struct node *n) { int ret; + + if (n->state != NODE_CREATED && n->state != NODE_STOPPED) + return -1; + + n->state = NODE_STARTING; info("Starting node %s", node_name_long(n)); { INDENT @@ -104,6 +109,8 @@ int node_stop(struct node *n) if (n->state != NODE_RUNNING) return -1; + + n->state = NODE_STOPPING; info("Stopping node %s", node_name(n));