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

index 535a4f55bce2e478361b1add06d2d277ef0d0c8e..9b6640f6b5547a283ba47a3ad467af8685eee39e 100644 (file)
@@ -176,15 +176,11 @@ void viewer_session_close_one_session(struct relay_viewer_session *vsession,
 
 void viewer_session_close(struct relay_viewer_session *vsession)
 {
-       struct relay_session *session;
-
-       {
-               const lttng::urcu::read_lock_guard read_lock;
-
-               cds_list_for_each_entry_rcu(session, &vsession->session_list, viewer_session_node)
-               {
-                       viewer_session_close_one_session(vsession, session);
-               }
+       for (auto *session :
+            lttng::urcu::rcu_list_iteration_adapter<relay_session,
+                                                    &relay_session::viewer_session_node>(
+                    vsession->session_list)) {
+               viewer_session_close_one_session(vsession, session);
        }
 }
 
@@ -194,7 +190,6 @@ void viewer_session_close(struct relay_viewer_session *vsession)
  */
 int viewer_session_is_attached(struct relay_viewer_session *vsession, struct relay_session *session)
 {
-       struct relay_session *iter;
        int found = 0;
 
        pthread_mutex_lock(&session->lock);
@@ -205,14 +200,13 @@ int viewer_session_is_attached(struct relay_viewer_session *vsession, struct rel
                goto end;
        }
 
-       {
-               const lttng::urcu::read_lock_guard read_lock;
-               cds_list_for_each_entry_rcu(iter, &vsession->session_list, viewer_session_node)
-               {
-                       if (session == iter) {
-                               found = 1;
-                               break;
-                       }
+       for (auto *session_it :
+            lttng::urcu::rcu_list_iteration_adapter<relay_session,
+                                                    &relay_session::viewer_session_node>(
+                    vsession->session_list)) {
+               if (session == session_it) {
+                       found = 1;
+                       break;
                }
        }
 
This page took 0.026016 seconds and 4 git commands to generate.