From: Jérémie Galarneau Date: Fri, 26 Jul 2024 20:07:03 +0000 (+0000) Subject: sessiond: event-notifier-error-accounting.cpp: iterate on lfht using lfht_iteration_a... X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=cad5fc86cc3cbc37c97f8889d07ca96ef9a0c97b;p=lttng-tools.git sessiond: event-notifier-error-accounting.cpp: iterate on lfht using lfht_iteration_adapter Change-Id: I8a4486f86e634187439b8e6c13fdd1a52fd051de Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/event-notifier-error-accounting.cpp b/src/bin/lttng-sessiond/event-notifier-error-accounting.cpp index 9672fdc6b..447585f7d 100644 --- a/src/bin/lttng-sessiond/event-notifier-error-accounting.cpp +++ b/src/bin/lttng-sessiond/event-notifier-error-accounting.cpp @@ -174,18 +174,14 @@ static void ust_error_accounting_entry_put(struct ust_error_accounting_entry *en */ static void put_ref_all_ust_error_accounting_entry() { - struct lttng_ht_iter iter; - struct ust_error_accounting_entry *uid_entry; - ASSERT_LOCKED(the_event_notifier_counter.lock); - { - const lttng::urcu::read_lock_guard read_lock; - - cds_lfht_for_each_entry ( - error_counter_uid_ht->ht, &iter.iter, uid_entry, node.node) { - ust_error_accounting_entry_put(uid_entry); - } + for (auto *uid_entry : + lttng::urcu::lfht_iteration_adapter( + *error_counter_uid_ht->ht)) { + ust_error_accounting_entry_put(uid_entry); } } @@ -194,18 +190,14 @@ static void put_ref_all_ust_error_accounting_entry() */ static void get_ref_all_ust_error_accounting_entry() { - struct lttng_ht_iter iter; - struct ust_error_accounting_entry *uid_entry; - ASSERT_LOCKED(the_event_notifier_counter.lock); - { - const lttng::urcu::read_lock_guard read_lock; - - cds_lfht_for_each_entry ( - error_counter_uid_ht->ht, &iter.iter, uid_entry, node.node) { - ust_error_accounting_entry_get(uid_entry); - } + for (auto *uid_entry : + lttng::urcu::lfht_iteration_adapter( + *error_counter_uid_ht->ht)) { + ust_error_accounting_entry_get(uid_entry); } } @@ -788,8 +780,6 @@ end: static enum event_notifier_error_accounting_status event_notifier_error_accounting_ust_get_count(const struct lttng_trigger *trigger, uint64_t *count) { - struct lttng_ht_iter iter; - struct ust_error_accounting_entry *uid_entry; uint64_t error_counter_index, global_sum = 0; enum event_notifier_error_accounting_status status; size_t dimension_indexes[1]; @@ -821,7 +811,11 @@ event_notifier_error_accounting_ust_get_count(const struct lttng_trigger *trigge * a trigger to a given sessiond is also allowed to create an event * notifier on all apps that this sessiond is aware of. */ - cds_lfht_for_each_entry (error_counter_uid_ht->ht, &iter.iter, uid_entry, node.node) { + for (auto *uid_entry : + lttng::urcu::lfht_iteration_adapter( + *error_counter_uid_ht->ht)) { int ret; int64_t local_value = 0; bool overflow = false, underflow = false; @@ -863,8 +857,6 @@ end: static enum event_notifier_error_accounting_status event_notifier_error_accounting_ust_clear(const struct lttng_trigger *trigger) { - struct lttng_ht_iter iter; - struct ust_error_accounting_entry *uid_entry; uint64_t error_counter_index; enum event_notifier_error_accounting_status status; size_t dimension_index; @@ -895,7 +887,11 @@ event_notifier_error_accounting_ust_clear(const struct lttng_trigger *trigger) * errors) can be generated from any applications that this session * daemon is managing. */ - cds_lfht_for_each_entry (error_counter_uid_ht->ht, &iter.iter, uid_entry, node.node) { + for (auto *uid_entry : + lttng::urcu::lfht_iteration_adapter( + *error_counter_uid_ht->ht)) { const int ret = lttng_ust_ctl_counter_clear(uid_entry->daemon_counter, &dimension_index);