sessiond: delete_ust_app_channel: iterate on lfht using lfht_iteration_adapter
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 22 Jul 2024 19:59:40 +0000 (19:59 +0000)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 30 Jul 2024 01:26:51 +0000 (01:26 +0000)
offsetof conditionally support for non-POD types and is used by
the cds_lfht_for_each_[...] macros. Replace them with
lfht_iteration_adapter which also provides ranged-for semantics.

Change-Id: I163697d83f235f46a1d70b596a34b6e010ec4169
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/ust-app.cpp

index 108812772b0507caa3faaefd1947062209601d40..e7f6952f7524ba550fd5df5b4838615a2795fa49 100644 (file)
@@ -564,9 +564,6 @@ static void delete_ust_app_channel(int sock,
                                   const lsu::registry_session::locked_ref& locked_registry)
 {
        int ret;
-       struct lttng_ht_iter iter;
-       struct ust_app_event *ua_event;
-       struct ust_app_ctx *ua_ctx;
        struct ust_app_stream *stream, *stmp;
 
        LTTNG_ASSERT(ua_chan);
@@ -581,16 +578,22 @@ static void delete_ust_app_channel(int sock,
        }
 
        /* Wipe context */
-       cds_lfht_for_each_entry (ua_chan->ctx->ht, &iter.iter, ua_ctx, node.node) {
+       for (auto ua_ctx :
+            lttng::urcu::lfht_iteration_adapter<ust_app_ctx,
+                                                decltype(ust_app_ctx::node),
+                                                &ust_app_ctx::node>(*ua_chan->ctx->ht)) {
                cds_list_del(&ua_ctx->list);
-               ret = lttng_ht_del(ua_chan->ctx, &iter);
+               ret = cds_lfht_del(ua_chan->ctx->ht, &ua_ctx->node.node);
                LTTNG_ASSERT(!ret);
                delete_ust_app_ctx(sock, ua_ctx, app);
        }
 
        /* Wipe events */
-       cds_lfht_for_each_entry (ua_chan->events->ht, &iter.iter, ua_event, node.node) {
-               ret = lttng_ht_del(ua_chan->events, &iter);
+       for (auto ua_event :
+            lttng::urcu::lfht_iteration_adapter<ust_app_event,
+                                                decltype(ust_app_event::node),
+                                                &ust_app_event::node>(*ua_chan->events->ht)) {
+               ret = cds_lfht_del(ua_chan->events->ht, &ua_event->node.node);
                LTTNG_ASSERT(!ret);
                delete_ust_app_event(sock, ua_event, app);
        }
@@ -616,6 +619,8 @@ static void delete_ust_app_channel(int sock,
        }
 
        if (ua_chan->obj != nullptr) {
+               lttng_ht_iter iter;
+
                /* Remove channel from application UST object descriptor. */
                iter.iter.node = &ua_chan->ust_objd_node.node;
                ret = lttng_ht_del(app->ust_objd, &iter);
This page took 0.027428 seconds and 4 git commands to generate.