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

index 453034490fc6a1e70f41b8fa0ca710c10c763a30..196656258171b5ea88e6bb9e1771c71e044ce1db 100644 (file)
@@ -84,24 +84,19 @@ process_attr_tracker_remove_value_node(struct process_attr_tracker *tracker,
 
 static void process_attr_tracker_clear_inclusion_set(struct process_attr_tracker *tracker)
 {
-       int ret;
-       struct lttng_ht_iter iter;
-       struct process_attr_tracker_value_node *value_node;
-
        if (!tracker->inclusion_set_ht) {
                return;
        }
 
-       {
-               const lttng::urcu::read_lock_guard read_lock;
-
-               cds_lfht_for_each_entry (
-                       tracker->inclusion_set_ht, &iter.iter, value_node, inclusion_set_ht_node) {
-                       process_attr_tracker_remove_value_node(tracker, value_node);
-               }
+       for (auto *value_node : lttng::urcu::lfht_iteration_adapter<
+                    process_attr_tracker_value_node,
+                    decltype(process_attr_tracker_value_node::inclusion_set_ht_node),
+                    &process_attr_tracker_value_node::inclusion_set_ht_node>(
+                    *tracker->inclusion_set_ht)) {
+               process_attr_tracker_remove_value_node(tracker, value_node);
        }
 
-       ret = cds_lfht_destroy(tracker->inclusion_set_ht, nullptr);
+       const auto ret = cds_lfht_destroy(tracker->inclusion_set_ht, nullptr);
        LTTNG_ASSERT(ret == 0);
        tracker->inclusion_set_ht = nullptr;
 }
@@ -257,8 +252,6 @@ enum process_attr_tracker_status
 process_attr_tracker_get_inclusion_set(const struct process_attr_tracker *tracker,
                                       struct lttng_process_attr_values **_values)
 {
-       struct lttng_ht_iter iter;
-       struct process_attr_tracker_value_node *value_node;
        enum process_attr_tracker_status status = PROCESS_ATTR_TRACKER_STATUS_OK;
        struct lttng_process_attr_values *values;
        struct process_attr_value *new_value = nullptr;
@@ -274,27 +267,26 @@ process_attr_tracker_get_inclusion_set(const struct process_attr_tracker *tracke
                goto error;
        }
 
-       {
-               const lttng::urcu::read_lock_guard read_lock;
-
-               cds_lfht_for_each_entry (
-                       tracker->inclusion_set_ht, &iter.iter, value_node, inclusion_set_ht_node) {
-                       int ret;
-
-                       new_value = process_attr_value_copy(value_node->value);
-                       if (!new_value) {
-                               status = PROCESS_ATTR_TRACKER_STATUS_ERROR;
-                               goto error_unlock;
-                       }
-
-                       ret = lttng_dynamic_pointer_array_add_pointer(&values->array, new_value);
-                       if (ret) {
-                               status = PROCESS_ATTR_TRACKER_STATUS_ERROR;
-                               goto error_unlock;
-                       }
+       for (auto *value_node : lttng::urcu::lfht_iteration_adapter<
+                    process_attr_tracker_value_node,
+                    decltype(process_attr_tracker_value_node::inclusion_set_ht_node),
+                    &process_attr_tracker_value_node::inclusion_set_ht_node>(
+                    *tracker->inclusion_set_ht)) {
+               int ret;
+
+               new_value = process_attr_value_copy(value_node->value);
+               if (!new_value) {
+                       status = PROCESS_ATTR_TRACKER_STATUS_ERROR;
+                       goto error_unlock;
+               }
 
-                       new_value = nullptr;
+               ret = lttng_dynamic_pointer_array_add_pointer(&values->array, new_value);
+               if (ret) {
+                       status = PROCESS_ATTR_TRACKER_STATUS_ERROR;
+                       goto error_unlock;
                }
+
+               new_value = nullptr;
        }
 
        *_values = values;
This page took 0.026919 seconds and 4 git commands to generate.