diff --git a/include/villas/hooks.h b/include/villas/hooks.h index 110e01ba6..f87f228d1 100644 --- a/include/villas/hooks.h +++ b/include/villas/hooks.h @@ -103,7 +103,7 @@ enum hook_type { HOOK_INIT = 1 << 9, /**< Called before path is started to parseHOOK_DESTROYs. */ HOOK_DESTROY = 1 << 10, /**< Called after path has been stopped to release memory allocated by HOOK_INIT */ - HOOK_INTERNAL = 1 << 11, /**< Internal hooks are added to every path implicitely. */ + HOOK_AUTO = 1 << 11, /**< Internal hooks are added to every path implicitely. */ HOOK_PARSE = 1 << 12, /**< Called for parsing hook arguments. */ /** @{ Classes of hooks */ @@ -113,9 +113,6 @@ enum hook_type { HOOK_PATH = HOOK_PATH_START | HOOK_PATH_STOP | HOOK_PATH_RESTART, /** Hooks which are used to collect statistics. */ HOOK_STATS = HOOK_INTERNAL | HOOK_STORAGE | HOOK_PATH | HOOK_READ | HOOK_PERIODIC, - - /** All hooks */ - HOOK_ALL = HOOK_INTERNAL - 1 /** @} */ }; diff --git a/lib/hooks/hooks-internal.c b/lib/hooks/hooks-internal.c index cb91505fd..5ce5cf705 100644 --- a/lib/hooks/hooks-internal.c +++ b/lib/hooks/hooks-internal.c @@ -12,14 +12,11 @@ #include "path.h" #include "utils.h" -REGISTER_HOOK("fix_ts", "Update timestamps of sample if not set", 0, 0, hook_fix_ts, HOOK_INTERNAL | HOOK_READ) +REGISTER_HOOK("fix_ts", "Update timestamps of sample if not set", 0, 0, hook_fix_ts, HOOK_AUTO | HOOK_READ) int hook_fix_ts(struct hook *h, int when, struct hook_info *j) { struct timespec now = time_now(); - if (when != HOOK_READ) - return 0; - assert(j->smps); for (int i = 0; i < j->cnt; i++) { @@ -41,12 +38,9 @@ int hook_fix_ts(struct hook *h, int when, struct hook_info *j) return j->cnt; } -REGISTER_HOOK("restart", "Call restart hooks for current path", 1, 1, hook_restart, HOOK_INTERNAL | HOOK_READ) +REGISTER_HOOK("restart", "Call restart hooks for current path", 1, 1, hook_restart, HOOK_AUTO | HOOK_READ) int hook_restart(struct hook *h, int when, struct hook_info *j) { - if (when != HOOK_READ) - return 0; - assert(j->smps); assert(j->path); @@ -69,14 +63,11 @@ int hook_restart(struct hook *h, int when, struct hook_info *j) return j->cnt; } -REGISTER_HOOK("drop", "Drop messages with reordered sequence numbers", 3, 1, hook_drop, HOOK_INTERNAL | HOOK_READ) +REGISTER_HOOK("drop", "Drop messages with reordered sequence numbers", 3, 1, hook_drop, HOOK_AUTO | HOOK_READ) int hook_drop(struct hook *h, int when, struct hook_info *j) { int i, ok, dist; - if (when != HOOK_READ) - return 0; - assert(j->smps); for (i = 0, ok = 0; i < j->cnt; i++) { diff --git a/lib/path.c b/lib/path.c index 4a9045072..18ab94b53 100644 --- a/lib/path.c +++ b/lib/path.c @@ -171,7 +171,7 @@ int path_init(struct path *p) /* Add internal hooks if they are not already in the list*/ list_foreach(struct hook *h, &hooks) { if ( - (h->type & HOOK_INTERNAL) && /* is internal hook? */ + (h->type & HOOK_AUTO) && /* should this hook be added implicitely? */ (list_lookup(&p->hooks, h->name) == NULL) /* is not already in list? */ ) list_push(&p->hooks, memdup(h, sizeof(struct hook)));