From 810111cdc74f5817dc79629dc175b305e21db497 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 22 Jul 2024 19:59:40 +0000 Subject: [PATCH] sessiond: delete_ust_app_channel: iterate on lfht using lfht_iteration_adapter MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/bin/lttng-sessiond/ust-app.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/bin/lttng-sessiond/ust-app.cpp b/src/bin/lttng-sessiond/ust-app.cpp index 108812772..e7f6952f7 100644 --- a/src/bin/lttng-sessiond/ust-app.cpp +++ b/src/bin/lttng-sessiond/ust-app.cpp @@ -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(*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(*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); -- 2.34.1