From 0ca5c4f9df6778d16a0dc3f74f7d3e256934058f Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Thu, 7 Nov 2019 15:35:08 -0500 Subject: [PATCH] Fix: src.ctf.lttng-live: removing trace when not all streams are done The following commit wrongfully added the removal of a live trace object: commit c28512ab93b16501a8b0da494f0a03e5f0f22662 Author: Francis Deslauriers Date: Mon Oct 28 14:49:08 2019 -0400 src.ctf.lttng-live: make `lttng_live_get_one_metadata_packet()` return status The live trace objects should only be removed once all its stream iterator have ended. We do that in next_stream_iterator_for_session() function. So, roll back this change but keep the switch statement so it's clearer what are the possible outcomes of the preceding function call. Signed-off-by: Francis Deslauriers Change-Id: I7ade43a256b731563eec2b1930724edbaeefd122 Reviewed-on: https://review.lttng.org/c/babeltrace/+/2350 Reviewed-by: Simon Marchi --- src/plugins/ctf/lttng-live/lttng-live.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/plugins/ctf/lttng-live/lttng-live.c b/src/plugins/ctf/lttng-live/lttng-live.c index efaec623..82ebbff9 100644 --- a/src/plugins/ctf/lttng-live/lttng-live.c +++ b/src/plugins/ctf/lttng-live/lttng-live.c @@ -493,22 +493,13 @@ enum lttng_live_iterator_status lttng_live_get_session( status = lttng_live_metadata_update(trace); switch (status) { + case LTTNG_LIVE_ITERATOR_STATUS_END: case LTTNG_LIVE_ITERATOR_STATUS_OK: trace_idx++; break; - case LTTNG_LIVE_ITERATOR_STATUS_END: - /* - * The trace has ended. Remove it of the array an - * continue the iteration. - * We can remove the trace safely when using the - * g_ptr_array_remove_index_fast because it replaces - * the element at trace_idx with the array's last - * element. trace_idx is not incremented because of - * that. - */ - (void) g_ptr_array_remove_index_fast(session->traces, - trace_idx); - break; + case LTTNG_LIVE_ITERATOR_STATUS_CONTINUE: + case LTTNG_LIVE_ITERATOR_STATUS_AGAIN: + goto end; default: BT_COMP_LOGE_APPEND_CAUSE(self_comp, "Error updating trace metadata: " -- 2.34.1