- cds_lfht_for_each_entry (sessions_ht->ht, &iter.iter, iterated_session, session_n.node) {
- if (!session_get(iterated_session)) {
- continue;
- }
-
- if (session == iterated_session) {
- /* Skip this session. */
- goto next_session_no_unlock;
- }
-
- pthread_mutex_lock(&iterated_session->lock);
-
- if (!iterated_session->id_sessiond.is_set) {
- /*
- * Session belongs to a peer that doesn't support
- * rotations.
- */
- goto next_session;
- }
-
- if (session->sessiond_uuid != iterated_session->sessiond_uuid) {
- /* Sessions do not originate from the same sessiond. */
- goto next_session;
- }
-
- if (LTTNG_OPTIONAL_GET(session->id_sessiond) !=
- LTTNG_OPTIONAL_GET(iterated_session->id_sessiond)) {
- /*
- * Sessions do not originate from the same sessiond
- * session.
- */
- goto next_session;
- }
-
- ongoing_rotation = iterated_session->ongoing_rotation;
-
- next_session:
- pthread_mutex_unlock(&iterated_session->lock);
- next_session_no_unlock:
- session_put(iterated_session);
-
- if (ongoing_rotation) {
- break;
+ {
+ lttng::urcu::read_lock_guard read_lock;
+
+ cds_lfht_for_each_entry (
+ sessions_ht->ht, &iter.iter, iterated_session, session_n.node) {
+ if (!session_get(iterated_session)) {
+ continue;
+ }
+
+ if (session == iterated_session) {
+ /* Skip this session. */
+ goto next_session_no_unlock;
+ }
+
+ pthread_mutex_lock(&iterated_session->lock);
+
+ if (!iterated_session->id_sessiond.is_set) {
+ /*
+ * Session belongs to a peer that doesn't support
+ * rotations.
+ */
+ goto next_session;
+ }
+
+ if (session->sessiond_uuid != iterated_session->sessiond_uuid) {
+ /* Sessions do not originate from the same sessiond. */
+ goto next_session;
+ }
+
+ if (LTTNG_OPTIONAL_GET(session->id_sessiond) !=
+ LTTNG_OPTIONAL_GET(iterated_session->id_sessiond)) {
+ /*
+ * Sessions do not originate from the same sessiond
+ * session.
+ */
+ goto next_session;
+ }
+
+ ongoing_rotation = iterated_session->ongoing_rotation;
+
+ next_session:
+ pthread_mutex_unlock(&iterated_session->lock);
+ next_session_no_unlock:
+ session_put(iterated_session);
+
+ if (ongoing_rotation) {
+ break;
+ }