relayd: main.cpp: iterate on rcu list using rcu_list_iteration_adapter
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 30 Jul 2024 19:43:01 +0000 (19:43 +0000)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 31 Jul 2024 03:36:52 +0000 (23:36 -0400)
Change-Id: Id3070b39458b3e44185875c87dca069c2dbb6ed6
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-relayd/main.cpp

index b18df2e9d6e43462d96b4d0403486f6fcb3a06f2..42ec33e52fe8826186702798b6cf2c51f51d9e47 100644 (file)
@@ -42,6 +42,7 @@
 #include <common/futex.hpp>
 #include <common/ini-config/ini-config.hpp>
 #include <common/path.hpp>
+#include <common/pthread-lock.hpp>
 #include <common/sessiond-comm/inet.hpp>
 #include <common/sessiond-comm/relayd.hpp>
 #include <common/sessiond-comm/sessiond-comm.hpp>
@@ -1511,17 +1512,17 @@ end:
  */
 static void publish_connection_local_streams(struct relay_connection *conn)
 {
-       struct relay_stream *stream;
        struct relay_session *session = conn->session;
 
        /*
         * We publish all streams belonging to a session atomically wrt
         * session lock.
         */
-       pthread_mutex_lock(&session->lock);
-       const lttng::urcu::read_lock_guard read_lock;
-       cds_list_for_each_entry_rcu(stream, &session->recv_list, recv_node)
-       {
+       const lttng::pthread::lock_guard session_lock(session->lock);
+
+       for (auto *stream :
+            lttng::urcu::rcu_list_iteration_adapter<relay_stream, &relay_stream::recv_node>(
+                    session->recv_list)) {
                stream_publish(stream);
        }
 
@@ -1531,8 +1532,6 @@ static void publish_connection_local_streams(struct relay_connection *conn)
        if (session->viewer_attached) {
                uatomic_set(&session->new_streams, 1);
        }
-
-       pthread_mutex_unlock(&session->lock);
 }
 
 static int conform_channel_path(char *channel_path)
This page took 0.026359 seconds and 4 git commands to generate.