From: Jérémie Galarneau Date: Tue, 30 Jul 2024 19:43:01 +0000 (+0000) Subject: relayd: main.cpp: iterate on rcu list using rcu_list_iteration_adapter X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=c7b9f8c3c3e023c7bf719e2547463d503149842d;p=lttng-tools.git relayd: main.cpp: iterate on rcu list using rcu_list_iteration_adapter Change-Id: Id3070b39458b3e44185875c87dca069c2dbb6ed6 Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-relayd/main.cpp b/src/bin/lttng-relayd/main.cpp index b18df2e9d..42ec33e52 100644 --- a/src/bin/lttng-relayd/main.cpp +++ b/src/bin/lttng-relayd/main.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -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( + 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)