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

index 9b592b8e0ec2869753717a8cb5358cb328464a01..b4c1a9216fc7a32956621b6d458aee1eb32d361b 100644 (file)
@@ -1308,22 +1308,18 @@ end:
 
 static void print_stream_indexes(struct relay_stream *stream)
 {
-       struct lttng_ht_iter iter;
-       struct relay_index *index;
-
-       {
-               const lttng::urcu::read_lock_guard read_lock;
-
-               cds_lfht_for_each_entry (stream->indexes_ht->ht, &iter.iter, index, index_n.node) {
-                       DBG("index %p net_seq_num %" PRIu64 " refcount %ld"
-                           " stream %" PRIu64 " trace %" PRIu64 " session %" PRIu64,
-                           index,
-                           index->index_n.key,
-                           stream->ref.refcount,
-                           index->stream->stream_handle,
-                           index->stream->trace->id,
-                           index->stream->trace->session->id);
-               }
+       for (auto *index :
+            lttng::urcu::lfht_iteration_adapter<relay_index,
+                                                decltype(relay_index::index_n),
+                                                &relay_index::index_n>(*stream->indexes_ht->ht)) {
+               DBG("index %p net_seq_num %" PRIu64 " refcount %ld"
+                   " stream %" PRIu64 " trace %" PRIu64 " session %" PRIu64,
+                   index,
+                   index->index_n.key,
+                   stream->ref.refcount,
+                   index->stream->stream_handle,
+                   index->stream->trace->id,
+                   index->stream->trace->session->id);
        }
 }
 
@@ -1360,30 +1356,25 @@ int stream_reset_file(struct relay_stream *stream)
 
 void print_relay_streams()
 {
-       struct lttng_ht_iter iter;
-       struct relay_stream *stream;
-
        if (!relay_streams_ht) {
                return;
        }
 
-       {
-               const lttng::urcu::read_lock_guard read_lock;
-
-               cds_lfht_for_each_entry (relay_streams_ht->ht, &iter.iter, stream, node.node) {
-                       if (!stream_get(stream)) {
-                               continue;
-                       }
-
-                       DBG("stream %p refcount %ld stream %" PRIu64 " trace %" PRIu64
-                           " session %" PRIu64,
-                           stream,
-                           stream->ref.refcount,
-                           stream->stream_handle,
-                           stream->trace->id,
-                           stream->trace->session->id);
-                       print_stream_indexes(stream);
-                       stream_put(stream);
+       for (auto *stream :
+            lttng::urcu::lfht_iteration_adapter<relay_stream,
+                                                decltype(relay_stream::node),
+                                                &relay_stream::node>(*relay_streams_ht->ht)) {
+               if (!stream_get(stream)) {
+                       continue;
                }
+
+               DBG("stream %p refcount %ld stream %" PRIu64 " trace %" PRIu64 " session %" PRIu64,
+                   stream,
+                   stream->ref.refcount,
+                   stream->stream_handle,
+                   stream->trace->id,
+                   stream->trace->session->id);
+               print_stream_indexes(stream);
+               stream_put(stream);
        }
 }
This page took 0.025961 seconds and 4 git commands to generate.