From eba3ef84e399d1668008b1348935cfb50ad37a6f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 26 Jul 2024 19:39:32 +0000 Subject: [PATCH] sessiond: buffer-registry.cpp: iterate on lfht using lfht_iteration_adapter MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I75daca3d9556c36bf2f08ec2c4c0184f2a2939e6 Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/buffer-registry.cpp | 57 +++++++++------------- 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/src/bin/lttng-sessiond/buffer-registry.cpp b/src/bin/lttng-sessiond/buffer-registry.cpp index bf1bd0a7c..fa04fdae5 100644 --- a/src/bin/lttng-sessiond/buffer-registry.cpp +++ b/src/bin/lttng-sessiond/buffer-registry.cpp @@ -333,28 +333,24 @@ int buffer_reg_uid_consumer_channel_key(struct cds_list_head *buffer_reg_uid_lis uint64_t chan_key, uint64_t *consumer_chan_key) { - struct lttng_ht_iter iter; - struct buffer_reg_uid *uid_reg = nullptr; - struct buffer_reg_session *session_reg = nullptr; - struct buffer_reg_channel *reg_chan; int ret = -1; - - { - const lttng::urcu::read_lock_guard read_lock; - - /* - * For the per-uid registry, we have to iterate since we don't have the - * uid and bitness key. - */ - cds_list_for_each_entry (uid_reg, buffer_reg_uid_list, lnode) { - session_reg = uid_reg->registry; - cds_lfht_for_each_entry ( - session_reg->channels->ht, &iter.iter, reg_chan, node.node) { - if (reg_chan->key == chan_key) { - *consumer_chan_key = reg_chan->consumer_key; - ret = 0; - goto end; - } + buffer_reg_uid *uid_reg = nullptr; + + /* + * For the per-uid registry, we have to iterate since we don't have the + * uid and bitness key. + */ + cds_list_for_each_entry (uid_reg, buffer_reg_uid_list, lnode) { + auto *session_reg = uid_reg->registry; + for (auto *reg_chan : + lttng::urcu::lfht_iteration_adapter( + *session_reg->channels->ht)) { + if (reg_chan->key == chan_key) { + *consumer_chan_key = reg_chan->consumer_key; + ret = 0; + goto end; } } } @@ -579,21 +575,16 @@ void buffer_reg_channel_destroy(struct buffer_reg_channel *regp, enum lttng_doma static void buffer_reg_session_destroy(struct buffer_reg_session *regp, enum lttng_domain_type domain) { - int ret; - struct lttng_ht_iter iter; - struct buffer_reg_channel *reg_chan; - DBG3("Buffer registry session destroy"); /* Destroy all channels. */ - { - const lttng::urcu::read_lock_guard read_lock; - - cds_lfht_for_each_entry (regp->channels->ht, &iter.iter, reg_chan, node.node) { - ret = lttng_ht_del(regp->channels, &iter); - LTTNG_ASSERT(!ret); - buffer_reg_channel_destroy(reg_chan, domain); - } + for (auto *reg_chan : + lttng::urcu::lfht_iteration_adapter(*regp->channels->ht)) { + const auto ret = cds_lfht_del(regp->channels->ht, ®_chan->node.node); + LTTNG_ASSERT(!ret); + buffer_reg_channel_destroy(reg_chan, domain); } lttng_ht_destroy(regp->channels); -- 2.34.1