From edfc8da747ee70d8b1280ca31167b19ae16ce7ab Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 26 Jul 2024 20:16:02 +0000 Subject: [PATCH] sessiond: event.cpp: iterate on lfht using lfht_iteration_adapter MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I12292f505e9f867898c92bcf6cbd81c10204d5d8 Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/event.cpp | 59 +++++++++++++------------------- 1 file changed, 24 insertions(+), 35 deletions(-) diff --git a/src/bin/lttng-sessiond/event.cpp b/src/bin/lttng-sessiond/event.cpp index bd28d948c..6d4dd6c26 100644 --- a/src/bin/lttng-sessiond/event.cpp +++ b/src/bin/lttng-sessiond/event.cpp @@ -319,24 +319,21 @@ error: int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan) { int ret, i, size, error = 0; - struct lttng_ht_iter iter; - struct ltt_ust_event *uevent = nullptr; struct lttng_event *events = nullptr; LTTNG_ASSERT(usess); LTTNG_ASSERT(uchan); /* Disabling existing events */ - { - const lttng::urcu::read_lock_guard read_lock; - - cds_lfht_for_each_entry (uchan->events->ht, &iter.iter, uevent, node.node) { - if (uevent->enabled) { - ret = event_ust_disable_tracepoint(usess, uchan, uevent->attr.name); - if (ret < 0) { - error = LTTNG_ERR_UST_DISABLE_FAIL; - continue; - } + for (auto *uevent : + lttng::urcu::lfht_iteration_adapter(*uchan->events->ht)) { + if (uevent->enabled) { + ret = event_ust_disable_tracepoint(usess, uchan, uevent->attr.name); + if (ret < 0) { + error = LTTNG_ERR_UST_DISABLE_FAIL; + continue; } } } @@ -365,16 +362,11 @@ error: static void agent_enable_all(struct agent *agt) { - struct agent_event *aevent; - struct lttng_ht_iter iter; - - { - /* Flag every event as enabled. */ - const lttng::urcu::read_lock_guard read_lock; - - cds_lfht_for_each_entry (agt->events->ht, &iter.iter, aevent, node.node) { - aevent->enabled_count++; - } + for (auto *aevent : + lttng::urcu::lfht_iteration_adapter(*agt->events->ht)) { + aevent->enabled_count++; } } @@ -908,8 +900,6 @@ end: int event_agent_disable_all(struct ltt_ust_session *usess, struct agent *agt) { int ret; - struct agent_event *aevent; - struct lttng_ht_iter iter; LTTNG_ASSERT(agt); LTTNG_ASSERT(usess); @@ -924,18 +914,17 @@ int event_agent_disable_all(struct ltt_ust_session *usess, struct agent *agt) } /* Disable every event. */ - { - const lttng::urcu::read_lock_guard read_lock; - - cds_lfht_for_each_entry (agt->events->ht, &iter.iter, aevent, node.node) { - if (!AGENT_EVENT_IS_ENABLED(aevent)) { - continue; - } + for (auto *aevent : + lttng::urcu::lfht_iteration_adapter(*agt->events->ht)) { + if (!AGENT_EVENT_IS_ENABLED(aevent)) { + continue; + } - ret = event_agent_disable(usess, agt, aevent->name); - if (ret != LTTNG_OK) { - goto error_unlock; - } + ret = event_agent_disable(usess, agt, aevent->name); + if (ret != LTTNG_OK) { + goto error_unlock; } } -- 2.34.1