From 1758ca2a0ca13a5571fcabd886e1ccadbf9ac11c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 26 Jul 2024 20:53:58 +0000 Subject: [PATCH] sessiond: session.cpp: iterate on lfht using lfht_iteration_adapter MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I2deae4866e0664e32cc40b891fc9e19b9936d66e Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/session.cpp | 35 ++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/bin/lttng-sessiond/session.cpp b/src/bin/lttng-sessiond/session.cpp index 69c06288b..9ad49c6fd 100644 --- a/src/bin/lttng-sessiond/session.cpp +++ b/src/bin/lttng-sessiond/session.cpp @@ -514,8 +514,6 @@ static int _session_set_trace_chunk_no_lock_check(const ltt_session::locked_ref& { int ret = 0; unsigned int i, refs_to_acquire = 0, refs_acquired = 0, refs_to_release = 0; - struct cds_lfht_iter iter; - struct consumer_socket *socket; struct lttng_trace_chunk *current_trace_chunk; uint64_t chunk_id; enum lttng_trace_chunk_status chunk_status; @@ -569,8 +567,12 @@ static int _session_set_trace_chunk_no_lock_check(const ltt_session::locked_ref& goto error; } } - cds_lfht_for_each_entry ( - session->ust_session->consumer->socks->ht, &iter, socket, node.node) { + + for (auto *socket : + lttng::urcu::lfht_iteration_adapter( + *session->ust_session->consumer->socks->ht)) { pthread_mutex_lock(socket->lock); ret = consumer_create_trace_chunk(socket, relayd_id, @@ -583,6 +585,7 @@ static int _session_set_trace_chunk_no_lock_check(const ltt_session::locked_ref& } } } + if (session->kernel_session) { const uint64_t relayd_id = session->kernel_session->consumer->net_seq_index; const bool is_local_trace = session->kernel_session->consumer->type == @@ -598,8 +601,12 @@ static int _session_set_trace_chunk_no_lock_check(const ltt_session::locked_ref& goto error; } } - cds_lfht_for_each_entry ( - session->kernel_session->consumer->socks->ht, &iter, socket, node.node) { + + for (auto *socket : + lttng::urcu::lfht_iteration_adapter( + *session->kernel_session->consumer->socks->ht)) { pthread_mutex_lock(socket->lock); ret = consumer_create_trace_chunk(socket, relayd_id, @@ -761,8 +768,6 @@ int session_close_trace_chunk(const ltt_session::locked_ref& session, { int ret = 0; bool error_occurred = false; - struct cds_lfht_iter iter; - struct consumer_socket *socket; enum lttng_trace_chunk_status chunk_status; const time_t chunk_close_timestamp = time(nullptr); const char *new_path; @@ -827,8 +832,11 @@ int session_close_trace_chunk(const ltt_session::locked_ref& session, if (session->ust_session) { const uint64_t relayd_id = session->ust_session->consumer->net_seq_index; - cds_lfht_for_each_entry ( - session->ust_session->consumer->socks->ht, &iter, socket, node.node) { + for (auto *socket : + lttng::urcu::lfht_iteration_adapter( + *session->ust_session->consumer->socks->ht)) { pthread_mutex_lock(socket->lock); ret = consumer_close_trace_chunk(socket, relayd_id, @@ -845,8 +853,11 @@ int session_close_trace_chunk(const ltt_session::locked_ref& session, if (session->kernel_session) { const uint64_t relayd_id = session->kernel_session->consumer->net_seq_index; - cds_lfht_for_each_entry ( - session->kernel_session->consumer->socks->ht, &iter, socket, node.node) { + for (auto *socket : + lttng::urcu::lfht_iteration_adapter( + *session->kernel_session->consumer->socks->ht)) { pthread_mutex_lock(socket->lock); ret = consumer_close_trace_chunk(socket, relayd_id, -- 2.39.5