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

index 70a750aec528e1c9dcf3dcb655273b16f96e3f84..5684495162dbdbd0b3ed907d3ef03e00a2ffff5d 100644 (file)
@@ -105,9 +105,6 @@ static int update_kernel_stream(int fd)
                ksess = session->kernel_session;
 
                cds_list_for_each_entry (channel, &ksess->channel_list.head, list) {
-                       struct lttng_ht_iter iter;
-                       struct consumer_socket *socket;
-
                        if (channel->fd != fd) {
                                continue;
                        }
@@ -129,21 +126,17 @@ static int update_kernel_stream(int fd)
                                goto error;
                        }
 
-                       {
-                               const lttng::urcu::read_lock_guard read_lock;
-
-                               cds_lfht_for_each_entry (
-                                       ksess->consumer->socks->ht, &iter.iter, socket, node.node) {
-                                       pthread_mutex_lock(socket->lock);
-                                       ret = kernel_consumer_send_channel_streams(
-                                               socket,
-                                               channel,
-                                               ksess,
-                                               session->output_traces ? 1 : 0);
-                                       pthread_mutex_unlock(socket->lock);
-                                       if (ret < 0) {
-                                               goto error;
-                                       }
+                       for (auto *socket :
+                            lttng::urcu::lfht_iteration_adapter<consumer_socket,
+                                                                decltype(consumer_socket::node),
+                                                                &consumer_socket::node>(
+                                    *ksess->consumer->socks->ht)) {
+                               pthread_mutex_lock(socket->lock);
+                               ret = kernel_consumer_send_channel_streams(
+                                       socket, channel, ksess, session->output_traces ? 1 : 0);
+                               pthread_mutex_unlock(socket->lock);
+                               if (ret < 0) {
+                                       goto error;
                                }
                        }
                }
This page took 0.025796 seconds and 4 git commands to generate.