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

index bf1bd0a7ca221aea294b58172882319be109dc95..fa04fdae54fcbdcee655f56bbfc8d79f62e92d85 100644 (file)
@@ -333,28 +333,24 @@ int buffer_reg_uid_consumer_channel_key(struct cds_list_head *buffer_reg_uid_lis
                                        uint64_t chan_key,
                                        uint64_t *consumer_chan_key)
 {
-       struct lttng_ht_iter iter;
-       struct buffer_reg_uid *uid_reg = nullptr;
-       struct buffer_reg_session *session_reg = nullptr;
-       struct buffer_reg_channel *reg_chan;
        int ret = -1;
-
-       {
-               const lttng::urcu::read_lock_guard read_lock;
-
-               /*
-                * For the per-uid registry, we have to iterate since we don't have the
-                * uid and bitness key.
-                */
-               cds_list_for_each_entry (uid_reg, buffer_reg_uid_list, lnode) {
-                       session_reg = uid_reg->registry;
-                       cds_lfht_for_each_entry (
-                               session_reg->channels->ht, &iter.iter, reg_chan, node.node) {
-                               if (reg_chan->key == chan_key) {
-                                       *consumer_chan_key = reg_chan->consumer_key;
-                                       ret = 0;
-                                       goto end;
-                               }
+       buffer_reg_uid *uid_reg = nullptr;
+
+       /*
+        * For the per-uid registry, we have to iterate since we don't have the
+        * uid and bitness key.
+        */
+       cds_list_for_each_entry (uid_reg, buffer_reg_uid_list, lnode) {
+               auto *session_reg = uid_reg->registry;
+               for (auto *reg_chan :
+                    lttng::urcu::lfht_iteration_adapter<buffer_reg_channel,
+                                                        decltype(buffer_reg_channel::node),
+                                                        &buffer_reg_channel::node>(
+                            *session_reg->channels->ht)) {
+                       if (reg_chan->key == chan_key) {
+                               *consumer_chan_key = reg_chan->consumer_key;
+                               ret = 0;
+                               goto end;
                        }
                }
        }
@@ -579,21 +575,16 @@ void buffer_reg_channel_destroy(struct buffer_reg_channel *regp, enum lttng_doma
 static void buffer_reg_session_destroy(struct buffer_reg_session *regp,
                                       enum lttng_domain_type domain)
 {
-       int ret;
-       struct lttng_ht_iter iter;
-       struct buffer_reg_channel *reg_chan;
-
        DBG3("Buffer registry session destroy");
 
        /* Destroy all channels. */
-       {
-               const lttng::urcu::read_lock_guard read_lock;
-
-               cds_lfht_for_each_entry (regp->channels->ht, &iter.iter, reg_chan, node.node) {
-                       ret = lttng_ht_del(regp->channels, &iter);
-                       LTTNG_ASSERT(!ret);
-                       buffer_reg_channel_destroy(reg_chan, domain);
-               }
+       for (auto *reg_chan :
+            lttng::urcu::lfht_iteration_adapter<buffer_reg_channel,
+                                                decltype(buffer_reg_channel::node),
+                                                &buffer_reg_channel::node>(*regp->channels->ht)) {
+               const auto ret = cds_lfht_del(regp->channels->ht, &reg_chan->node.node);
+               LTTNG_ASSERT(!ret);
+               buffer_reg_channel_destroy(reg_chan, domain);
        }
 
        lttng_ht_destroy(regp->channels);
This page took 0.026957 seconds and 4 git commands to generate.