sessiond: event.cpp: iterate on lfht using lfht_iteration_adapter
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 26 Jul 2024 20:16:02 +0000 (20:16 +0000)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 30 Jul 2024 01:26:51 +0000 (01:26 +0000)
Change-Id: I12292f505e9f867898c92bcf6cbd81c10204d5d8
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/event.cpp

index bd28d948c533b76751fec7033a7ac0063f3ed2c1..6d4dd6c26f40317129ea606b97c81ca286c124dd 100644 (file)
@@ -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<ltt_ust_event,
+                                                decltype(ltt_ust_event::node),
+                                                &ltt_ust_event::node>(*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<agent_event,
+                                                decltype(agent_event::node),
+                                                &agent_event::node>(*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<agent_event,
+                                                decltype(agent_event::node),
+                                                &agent_event::node>(*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;
                }
        }
 
This page took 0.027787 seconds and 4 git commands to generate.