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

index d326e30dd88a37b8b33c7f17ddd387c8804ae1a1..69e4ff79de7c493269ce04910c665e56e889242a 100644 (file)
@@ -243,14 +243,13 @@ void snapshot_output_destroy(struct snapshot_output *obj)
  */
 struct snapshot_output *snapshot_find_output_by_name(const char *name, struct snapshot *snapshot)
 {
-       struct lttng_ht_iter iter;
-       struct snapshot_output *output = nullptr;
-
        LTTNG_ASSERT(snapshot);
        LTTNG_ASSERT(name);
-       ASSERT_RCU_READ_LOCKED();
 
-       cds_lfht_for_each_entry (snapshot->output_ht->ht, &iter.iter, output, node.node) {
+       for (auto *output : lttng::urcu::lfht_iteration_adapter<snapshot_output,
+                                                               decltype(snapshot_output::node),
+                                                               &snapshot_output::node>(
+                    *snapshot->output_ht->ht)) {
                if (!strncmp(output->name, name, strlen(name))) {
                        return output;
                }
@@ -318,20 +317,16 @@ error:
  */
 void snapshot_destroy(struct snapshot *obj)
 {
-       struct lttng_ht_iter iter;
-       struct snapshot_output *output;
-
        if (!obj->output_ht) {
                return;
        }
 
-       {
-               const lttng::urcu::read_lock_guard read_lock;
-
-               cds_lfht_for_each_entry (obj->output_ht->ht, &iter.iter, output, node.node) {
-                       snapshot_delete_output(obj, output);
-                       snapshot_output_destroy(output);
-               }
+       for (auto *output :
+            lttng::urcu::lfht_iteration_adapter<snapshot_output,
+                                                decltype(snapshot_output::node),
+                                                &snapshot_output::node>(*obj->output_ht->ht)) {
+               snapshot_delete_output(obj, output);
+               snapshot_output_destroy(output);
        }
 
        lttng_ht_destroy(obj->output_ht);
This page took 0.025453 seconds and 4 git commands to generate.