mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
hooks: improve error handling
This commit is contained in:
parent
f1c51c6b95
commit
802f5d1c1e
3 changed files with 16 additions and 8 deletions
|
@ -187,11 +187,11 @@ int hook_parse_list(struct list *list, config_setting_t *cfg, struct path *o)
|
|||
|
||||
ret = hook_init(h, &p->hook, o);
|
||||
if (ret)
|
||||
continue;
|
||||
cerror(cfg_hook, "Failed to initialize hook");
|
||||
|
||||
ret = hook_parse(h, cfg_hook);
|
||||
if (ret)
|
||||
continue;
|
||||
cerror(cfg_hook, "Failed to parse hook configuration");
|
||||
|
||||
list_push(list, h);
|
||||
}
|
||||
|
|
|
@ -59,8 +59,8 @@ static int stats_collect_init(struct hook *h)
|
|||
p->buckets = 20;
|
||||
p->uri = NULL;
|
||||
p->output = stdout;
|
||||
|
||||
return 0;
|
||||
|
||||
return stats_init(&p->stats, p->buckets, p->warmup);
|
||||
}
|
||||
|
||||
static int stats_collect_destroy(struct hook *h)
|
||||
|
@ -74,7 +74,7 @@ static int stats_collect_start(struct hook *h)
|
|||
{
|
||||
struct stats_collect *p = h->_vd;
|
||||
|
||||
stats_init(&p->stats, p->buckets, p->warmup);
|
||||
|
||||
|
||||
if (p->uri) {
|
||||
p->output = fopen(p->uri, "w+");
|
||||
|
|
14
src/hook.c
14
src/hook.c
|
@ -161,7 +161,9 @@ int main(int argc, char *argv[])
|
|||
if (ret)
|
||||
error("Failed to parse hook config");
|
||||
|
||||
hook_start(&h);
|
||||
ret = hook_start(&h);
|
||||
if (ret)
|
||||
error("Failed to start hook");
|
||||
|
||||
while (!feof(stdin)) {
|
||||
ret = sample_alloc(&q, samples, cnt);
|
||||
|
@ -190,8 +192,14 @@ int main(int argc, char *argv[])
|
|||
sample_free(samples, cnt);
|
||||
}
|
||||
|
||||
hook_stop(&h);
|
||||
hook_destroy(&h);
|
||||
ret = hook_stop(&h);
|
||||
if (ret)
|
||||
error("Failed to stop hook");
|
||||
|
||||
ret = hook_destroy(&h);
|
||||
if (ret)
|
||||
error("Failed to destroy hook");
|
||||
|
||||
config_destroy(&cfg);
|
||||
|
||||
sample_free(samples, cnt);
|
||||
|
|
Loading…
Add table
Reference in a new issue