From 69a16b2ac70e0816f3663b8b4f2584d56c25e727 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Thu, 20 Oct 2016 18:04:18 -0400 Subject: [PATCH] added a couple of states to the path FSM --- include/villas/path.h | 6 ++++-- lib/path.c | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/villas/path.h b/include/villas/path.h index 654131e2e..abd1dfbc2 100644 --- a/include/villas/path.h +++ b/include/villas/path.h @@ -35,9 +35,11 @@ struct path { enum { PATH_INVALID, /**< Path is invalid. */ - PATH_CREATED, /**< Path has been created. */ + PATH_CREATED, /**< Path has been created: lists initialized */ + PATH_INITIALIZED, /**< Path queues, memory pools & hook system initialized. */ PATH_RUNNING, /**< Path is currently running. */ - PATH_STOPPED /**< Path has been stopped. */ + PATH_STOPPED, /**< Path has been stopped. */ + PATH_DESTROYED /**< Path is destroyed. */ } state; /**< Path state */ struct node *in; /**< Pointer to the incoming node */ diff --git a/lib/path.c b/lib/path.c index ec8e100ba..dde5b0e0e 100644 --- a/lib/path.c +++ b/lib/path.c @@ -120,11 +120,11 @@ int path_stop(struct path *p) pthread_cancel(p->recv_tid); pthread_join(p->recv_tid, NULL); - p->state = PATH_STOPPED; - if (hook_run(p, NULL, 0, HOOK_PATH_STOP)) return -1; + p->state = PATH_STOPPED; + return 0; } @@ -179,6 +179,8 @@ int path_prepare(struct path *p) ret = queue_init(&p->queue, p->queuelen, &memtype_hugepage); if (ret) error("Failed to initialize queue for path"); + + p->state = PATH_INITIALIZED; return 0; } @@ -192,6 +194,8 @@ void path_destroy(struct path *p) queue_destroy(&p->queue); pool_destroy(&p->pool); + + p->state = PATH_DESTROYED; free(p->_name); }