relayd: viewer-session.cpp: iterate on lfht using lfht_iteration_adapter
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 26 Jul 2024 19:15:48 +0000 (19:15 +0000)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 30 Jul 2024 01:26:51 +0000 (01:26 +0000)
Change-Id: Ice79de9905f6fd374c6de897541ac7915a3f8231
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-relayd/viewer-session.cpp

index 176cdc525ad38c235c7d5f1ea5090de5f40ebdcb..535a4f55bce2e478361b1add06d2d277ef0d0c8e 100644 (file)
@@ -143,34 +143,30 @@ void viewer_session_destroy(struct relay_viewer_session *vsession)
 void viewer_session_close_one_session(struct relay_viewer_session *vsession,
                                      struct relay_session *session)
 {
-       struct lttng_ht_iter iter;
-       struct relay_viewer_stream *vstream;
-
        /*
         * TODO: improvement: create more efficient list of
         * vstream per session.
         */
-       {
-               const lttng::urcu::read_lock_guard read_guard;
-
-               cds_lfht_for_each_entry (
-                       viewer_streams_ht->ht, &iter.iter, vstream, stream_n.node) {
-                       if (!viewer_stream_get(vstream)) {
-                               continue;
-                       }
-                       if (vstream->stream->trace->session != session) {
-                               viewer_stream_put(vstream);
-                               continue;
-                       }
-                       /* Put local reference. */
-                       viewer_stream_put(vstream);
-                       /*
-                        * We have reached one of the viewer stream's lifetime
-                        * end condition. This "put" will cause the proper
-                        * teardown of the viewer stream.
-                        */
+       for (auto *vstream :
+            lttng::urcu::lfht_iteration_adapter<relay_viewer_stream,
+                                                decltype(relay_viewer_stream::stream_n),
+                                                &relay_viewer_stream::stream_n>(
+                    *viewer_streams_ht->ht)) {
+               if (!viewer_stream_get(vstream)) {
+                       continue;
+               }
+               if (vstream->stream->trace->session != session) {
                        viewer_stream_put(vstream);
+                       continue;
                }
+               /* Put local reference. */
+               viewer_stream_put(vstream);
+               /*
+                * We have reached one of the viewer stream's lifetime
+                * end condition. This "put" will cause the proper
+                * teardown of the viewer stream.
+                */
+               viewer_stream_put(vstream);
        }
 
        lttng_trace_chunk_put(vsession->current_trace_chunk);
This page took 0.025595 seconds and 4 git commands to generate.