From: Jérémie Galarneau Date: Fri, 26 Jul 2024 19:15:48 +0000 (+0000) Subject: relayd: viewer-session.cpp: iterate on lfht using lfht_iteration_adapter X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=33b7f82ce73daba7490fc4e9cd8fbab03a0e982b;p=lttng-tools.git relayd: viewer-session.cpp: iterate on lfht using lfht_iteration_adapter Change-Id: Ice79de9905f6fd374c6de897541ac7915a3f8231 Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-relayd/viewer-session.cpp b/src/bin/lttng-relayd/viewer-session.cpp index 176cdc525..535a4f55b 100644 --- a/src/bin/lttng-relayd/viewer-session.cpp +++ b/src/bin/lttng-relayd/viewer-session.cpp @@ -143,34 +143,30 @@ void viewer_session_destroy(struct relay_viewer_session *vsession) void viewer_session_close_one_session(struct relay_viewer_session *vsession, struct relay_session *session) { - struct lttng_ht_iter iter; - struct relay_viewer_stream *vstream; - /* * TODO: improvement: create more efficient list of * vstream per session. */ - { - const lttng::urcu::read_lock_guard read_guard; - - cds_lfht_for_each_entry ( - viewer_streams_ht->ht, &iter.iter, vstream, stream_n.node) { - if (!viewer_stream_get(vstream)) { - continue; - } - if (vstream->stream->trace->session != session) { - viewer_stream_put(vstream); - continue; - } - /* Put local reference. */ - viewer_stream_put(vstream); - /* - * We have reached one of the viewer stream's lifetime - * end condition. This "put" will cause the proper - * teardown of the viewer stream. - */ + for (auto *vstream : + lttng::urcu::lfht_iteration_adapter( + *viewer_streams_ht->ht)) { + if (!viewer_stream_get(vstream)) { + continue; + } + if (vstream->stream->trace->session != session) { viewer_stream_put(vstream); + continue; } + /* Put local reference. */ + viewer_stream_put(vstream); + /* + * We have reached one of the viewer stream's lifetime + * end condition. This "put" will cause the proper + * teardown of the viewer stream. + */ + viewer_stream_put(vstream); } lttng_trace_chunk_put(vsession->current_trace_chunk);