1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

path: pass struct path to source and destinations in ctors

This commit is contained in:
Steffen Vogel 2021-06-19 13:27:33 -04:00
parent 10d944bcf9
commit 7135174df9
5 changed files with 19 additions and 13 deletions

View file

@ -37,11 +37,12 @@ struct sample;
struct vpath_destination {
struct vnode *node;
struct vpath *path;
struct queue queue;
};
int path_destination_init(struct vpath_destination *pd, struct vnode *n) __attribute__ ((warn_unused_result));
int path_destination_init(struct vpath_destination *pd, struct vpath *p, struct vnode *n) __attribute__ ((warn_unused_result));
int path_destination_destroy(struct vpath_destination *pd) __attribute__ ((warn_unused_result));

View file

@ -43,6 +43,7 @@ enum PathSourceType {
struct vpath_source {
struct vnode *node;
struct vpath *path;
bool masked;
@ -53,14 +54,14 @@ struct vpath_source {
struct vlist secondaries; /**< List of secondary path sources (struct path_sourced). */
};
int path_source_init_master(struct vpath_source *ps, struct vnode *n) __attribute__ ((warn_unused_result));
int path_source_init_master(struct vpath_source *ps, struct vpath *p, struct vnode *n) __attribute__ ((warn_unused_result));
int path_source_init_secondary(struct vpath_source *ps, struct vnode *n) __attribute__ ((warn_unused_result));
int path_source_init_secondary(struct vpath_source *ps, struct vpath *p, struct vnode *n) __attribute__ ((warn_unused_result));
int path_source_destroy(struct vpath_source *ps) __attribute__ ((warn_unused_result));
void path_source_check(struct vpath_source *ps);
int path_source_read(struct vpath_source *ps, struct vpath *p, int i);
int path_source_read(struct vpath_source *ps, int i);
/** @} */

View file

@ -69,7 +69,7 @@ static void * path_run_single(void *arg)
while (p->state == State::STARTED) {
pthread_testcancel();
ret = path_source_read(ps, p, 0);
ret = path_source_read(ps, 0);
if (ret <= 0)
continue;
@ -115,7 +115,7 @@ static void * path_run_poll(void *arg)
}
/* A source is ready to receive samples */
else
path_source_read(ps, p, i);
path_source_read(ps, i);
}
}
@ -276,8 +276,8 @@ int path_prepare(struct vpath *p, NodeList &nodes)
*/
bool isSecondary = vlist_length(&n->sources) > 0;
ret = isSecondary
? path_source_init_secondary(ps, n)
: path_source_init_master(ps, n);
? path_source_init_secondary(ps, p, n)
: path_source_init_master(ps, p, n);
if (ret)
return ret;
@ -481,7 +481,7 @@ int path_parse(struct vpath *p, json_t *json, NodeList &nodes, const uuid_t sn_u
if (!pd)
throw MemoryAllocationError();
ret = path_destination_init(pd, n);
ret = path_destination_init(pd, p, n);
if (ret)
return ret;

View file

@ -30,9 +30,11 @@
using namespace villas;
int path_destination_init(struct vpath_destination *pd, struct vnode *n)
int path_destination_init(struct vpath_destination *pd, struct vpath *p, struct vnode *n)
{
pd->node = n;
pd->path = p;
vlist_push(&n->destinations, pd);

View file

@ -36,11 +36,12 @@
using namespace villas;
int path_source_init_master(struct vpath_source *ps, struct vnode *n)
int path_source_init_master(struct vpath_source *ps, struct vpath *p, struct vnode *n)
{
int ret;
ps->node = n;
ps->path = p;
ps->masked = false;
ps->type = PathSourceType::MASTER;
@ -64,7 +65,7 @@ int path_source_init_master(struct vpath_source *ps, struct vnode *n)
return 0;
}
int path_source_init_secondary(struct vpath_source *ps, struct vnode *n)
int path_source_init_secondary(struct vpath_source *ps, struct vpath *p, struct vnode *n)
{
int ret;
struct vpath_source *mps;
@ -75,6 +76,7 @@ int path_source_init_secondary(struct vpath_source *ps, struct vnode *n)
ps->type = PathSourceType::SECONDARY;
ps->path = p;
ps->node = loopback_internal_create(n);
if (!ps->node)
return -1;
@ -115,7 +117,7 @@ int path_source_destroy(struct vpath_source *ps)
return 0;
}
int path_source_read(struct vpath_source *ps, struct vpath *p, int i)
int path_source_read(struct vpath_source *ps, int i)
{
int ret, recv, tomux, allocated, cnt, toenqueue, enqueued = 0;