- session_lock_list();
- cds_list_for_each_entry(session, &session_list->head, list) {
- if (!session_get(session)) {
- continue;
- }
- session_lock(session);
- if (session->kernel_session == NULL) {
- session_unlock(session);
- session_put(session);
+ const auto list_lock = lttng::sessiond::lock_session_list();
+ const struct ltt_session_list *session_list = session_get_list();
+
+ for (auto *raw_session_ptr :
+ lttng::urcu::list_iteration_adapter<ltt_session, <t_session::list>(
+ session_list->head)) {
+ ltt_kernel_session *ksess;
+
+ const auto session = [raw_session_ptr]() {
+ session_get(raw_session_ptr);
+ raw_session_ptr->lock();
+ return ltt_session::make_locked_ref(*raw_session_ptr);
+ }();
+
+ if (session->kernel_session == nullptr) {