Fix: src.ctf.lttng-live: decode metadata even on _STATUS_CLOSED
[babeltrace.git] / src / plugins / ctf / lttng-live / lttng-live.c
index efaec623fab9bf4eb51feec70cbf3d1165bf0a01..078fe94d787289cdea05249946aa194f48172205 100644 (file)
@@ -196,7 +196,7 @@ struct lttng_live_trace *lttng_live_create_trace(struct lttng_live_session *sess
        trace->stream_iterators = g_ptr_array_new_with_free_func(
                (GDestroyNotify) lttng_live_stream_iterator_destroy);
        BT_ASSERT(trace->stream_iterators);
-       trace->new_metadata_needed = true;
+       trace->metadata_stream_state = LTTNG_LIVE_METADATA_STREAM_STATE_NEEDED;
        g_ptr_array_add(session->traces, trace);
 
        goto end;
@@ -395,7 +395,8 @@ enum lttng_live_iterator_status lttng_live_iterator_next_handle_one_no_data_stre
        enum lttng_live_stream_state orig_state = lttng_live_stream->state;
        struct packet_index index;
 
-       if (lttng_live_stream->trace->new_metadata_needed) {
+       if (lttng_live_stream->trace->metadata_stream_state ==
+                       LTTNG_LIVE_METADATA_STREAM_STATE_NEEDED) {
                ret = LTTNG_LIVE_ITERATOR_STATUS_CONTINUE;
                goto end;
        }
@@ -493,22 +494,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: "
@@ -552,7 +544,11 @@ void lttng_live_force_new_streams_and_metadata(struct lttng_live_msg_iter *lttng
                                trace_idx++) {
                        struct lttng_live_trace *trace =
                                g_ptr_array_index(session->traces, trace_idx);
-                       trace->new_metadata_needed = true;
+
+                       BT_ASSERT(trace->metadata_stream_state !=
+                               LTTNG_LIVE_METADATA_STREAM_STATE_CLOSED);
+
+                       trace->metadata_stream_state = LTTNG_LIVE_METADATA_STREAM_STATE_NEEDED;
                }
        }
 }
@@ -819,7 +815,7 @@ enum lttng_live_iterator_status lttng_live_iterator_next_handle_one_active_data_
                                trace_idx++) {
                        struct lttng_live_trace *trace =
                                g_ptr_array_index(session->traces, trace_idx);
-                       if (trace->new_metadata_needed) {
+                       if (trace->metadata_stream_state == LTTNG_LIVE_METADATA_STREAM_STATE_NEEDED) {
                                ret = LTTNG_LIVE_ITERATOR_STATUS_CONTINUE;
                                goto end;
                        }
This page took 0.025016 seconds and 4 git commands to generate.