Skip to content

Commit

Permalink
Interpose rail update callback to inject rail handle during update
Browse files Browse the repository at this point in the history
Ensure that the update operation is handled by `__rail_update()`, allowing the
rail handle to be delivered upon update completion
  • Loading branch information
nichamon authored and tom95858 committed Sep 5, 2024
1 parent d4e1f80 commit 67a1828
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
14 changes: 12 additions & 2 deletions ldms/src/core/ldms.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,10 +773,20 @@ int __ldms_xprt_update(ldms_t x, struct ldms_set *set, ldms_update_cb_t cb, void
return rc;
}

/* Implementation is in ldms_rail.c */
ldms_t __ldms_xprt_to_rail(ldms_t x);
int ldms_xprt_update(struct ldms_set *set, ldms_update_cb_t cb, void *arg)
{
ldms_t x = set->xprt;
return x->ops.update(x, set, cb, arg);
/*
* We convert the transport handle to a rail handle using
* __ldms_xprt_to_rail() and pass it to x->ops.update().
* This ensures that the update operation will be handled
* by the __rail_update() function, which allows us to
* interpose the rail update callback and deliver the rail handle
* when the update completes.
*/
ldms_t r = __ldms_xprt_to_rail(set->xprt);
return r->ops.update(r, set, cb, arg);
}

void __ldms_set_on_xprt_term(ldms_set_t set, ldms_t xprt)
Expand Down
6 changes: 3 additions & 3 deletions ldms/src/core/ldms_rail.c
Original file line number Diff line number Diff line change
Expand Up @@ -1271,9 +1271,9 @@ struct ldms_rail_update_ctxt_s {

void __rail_update_cb(ldms_t x, ldms_set_t s, int flags, void *arg)
{
ldms_rail_t r = ldms_xprt_ctxt_get(x);
struct ldms_rail_ep_s *rep = ldms_xprt_ctxt_get(x);
ldms_rail_update_ctxt_t uc = arg;
uc->app_cb((ldms_t)r, s, flags, uc->cb_arg);
uc->app_cb((ldms_t)rep->rail, s, flags, uc->cb_arg);
if (!(flags & LDMS_UPD_F_MORE)) {
free(uc);
}
Expand All @@ -1292,7 +1292,7 @@ static int __rail_update(ldms_t _r, struct ldms_set *set,
uc->r = r;
uc->app_cb = cb;
uc->cb_arg = arg;
rc = ldms_xprt_update(set, __rail_update_cb, uc);
rc = set->xprt->ops.update(set->xprt, set, __rail_update_cb, uc);
if (rc) {
/* synchronously error, clean up the context */
free(uc);
Expand Down

0 comments on commit 67a1828

Please sign in to comment.