diff --git a/include/villas/path_destination.h b/include/villas/path_destination.h index b5aca6b82..8cb9deb96 100644 --- a/include/villas/path_destination.h +++ b/include/villas/path_destination.h @@ -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)); diff --git a/include/villas/path_source.h b/include/villas/path_source.h index c3cc237da..326ce576f 100644 --- a/include/villas/path_source.h +++ b/include/villas/path_source.h @@ -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); /** @} */ diff --git a/lib/path.cpp b/lib/path.cpp index 0360d781b..4d1427ea2 100644 --- a/lib/path.cpp +++ b/lib/path.cpp @@ -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; diff --git a/lib/path_destination.cpp b/lib/path_destination.cpp index 08fdad672..a43b6dc47 100644 --- a/lib/path_destination.cpp +++ b/lib/path_destination.cpp @@ -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); diff --git a/lib/path_source.cpp b/lib/path_source.cpp index 58d20f59c..1c4ac2a32 100644 --- a/lib/path_source.cpp +++ b/lib/path_source.cpp @@ -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;