From 05a43a0c8585145dbd23c01f75a248f362493dd2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 26 Jul 2024 19:13:44 +0000 Subject: [PATCH] relayd: stream.cpp: iterate on lfht using lfht_iteration_adapter MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I42d455ed488a5992705a5e59ac55104da948b592 Signed-off-by: Jérémie Galarneau --- src/bin/lttng-relayd/stream.cpp | 63 ++++++++++++++------------------- 1 file changed, 27 insertions(+), 36 deletions(-) diff --git a/src/bin/lttng-relayd/stream.cpp b/src/bin/lttng-relayd/stream.cpp index 9b592b8e0..b4c1a9216 100644 --- a/src/bin/lttng-relayd/stream.cpp +++ b/src/bin/lttng-relayd/stream.cpp @@ -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(*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_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); } } -- 2.34.1