Visibility hidden by default
[babeltrace.git] / src / plugins / ctf / lttng-live / lttng-live.cpp
index 63fc173f689cd20f956ba2ba6810cf3e6bc7fa8e..be6d7ba97adfacb0907c3493db9943e8d56c582a 100644 (file)
@@ -108,7 +108,6 @@ void lttng_live_stream_iterator_set_state(struct lttng_live_stream_iterator *str
                      live_stream_iter->current_inactivity_ts);                                     \
     } while (0);
 
-BT_HIDDEN
 bool lttng_live_graph_is_canceled(struct lttng_live_msg_iter *msg_iter)
 {
     bool ret;
@@ -195,7 +194,6 @@ end:
     return trace;
 }
 
-BT_HIDDEN
 struct lttng_live_trace *
 lttng_live_session_borrow_or_create_trace_by_id(struct lttng_live_session *session,
                                                 uint64_t trace_id)
@@ -214,7 +212,6 @@ end:
     return trace;
 }
 
-BT_HIDDEN
 int lttng_live_add_session(struct lttng_live_msg_iter *lttng_live_msg_iter, uint64_t session_id,
                            const char *hostname, const char *session_name)
 {
@@ -321,7 +318,6 @@ end:
     return;
 }
 
-BT_HIDDEN
 void lttng_live_msg_iter_finalize(bt_self_message_iterator *self_msg_iter)
 {
     struct lttng_live_msg_iter *lttng_live_msg_iter;
@@ -412,10 +408,10 @@ static enum lttng_live_iterator_status lttng_live_iterator_next_handle_one_no_da
 
         if (orig_state == LTTNG_LIVE_STREAM_QUIESCENT_NO_DATA && last_inact_ts == curr_inact_ts) {
             /*
-                        * Because the stream is in the QUIESCENT_NO_DATA
-                        * state, we can assert that the last_inactivity_ts was
-                        * set and can be safely used in the `if` above.
-                        */
+             * Because the stream is in the QUIESCENT_NO_DATA
+             * state, we can assert that the last_inactivity_ts was
+             * set and can be safely used in the `if` above.
+             */
             BT_ASSERT(lttng_live_stream->last_inactivity_ts.is_set);
 
             ret = LTTNG_LIVE_ITERATOR_STATUS_AGAIN;
@@ -481,15 +477,42 @@ lttng_live_get_session(struct lttng_live_msg_iter *lttng_live_msg_iter,
         }
     }
 
-    BT_COMP_LOGD("Updating all streams and metadata for session: "
+    BT_COMP_LOGD("Updating all data streams: "
                  "session-id=%" PRIu64 ", session-name=\"%s\"",
                  session->id, session->session_name->str);
 
     status = lttng_live_session_get_new_streams(session, lttng_live_msg_iter->self_msg_iter);
-    if (status != LTTNG_LIVE_ITERATOR_STATUS_OK && status != LTTNG_LIVE_ITERATOR_STATUS_END) {
+    switch (status) {
+    case LTTNG_LIVE_ITERATOR_STATUS_OK:
+        break;
+    case LTTNG_LIVE_ITERATOR_STATUS_END:
+        /*
+                * We received a `_END` from the `_get_new_streams()` function,
+                * which means no more data will ever be received from the data
+                * streams of this session. But it's possible that the metadata
+                * is incomplete.
+                * The live protocol guarantees that we receive all the
+                * metadata needed before we receive data streams needing it.
+                * But it's possible to receive metadata NOT needed by
+                * data streams after the session was closed. For example, this
+                * could happen if a new event is registered and the session is
+                * stopped before any tracepoint for that event is actually
+                * fired.
+                */
+        BT_COMP_LOGD(
+            "Updating streams returned _END status. Override status to _OK in order fetch any remaining metadata:"
+            "session-id=%" PRIu64 ", session-name=\"%s\"",
+            session->id, session->session_name->str);
+        status = LTTNG_LIVE_ITERATOR_STATUS_OK;
+        break;
+    default:
         goto end;
     }
 
+    BT_COMP_LOGD("Updating metadata stream for session: "
+                 "session-id=%" PRIu64 ", session-name=\"%s\"",
+                 session->id, session->session_name->str);
+
     trace_idx = 0;
     while (trace_idx < session->traces->len) {
         struct lttng_live_trace *trace =
@@ -608,6 +631,11 @@ lttng_live_iterator_handle_new_streams_and_metadata(struct lttng_live_msg_iter *
         switch (status) {
         case LTTNG_LIVE_ITERATOR_STATUS_OK:
         case LTTNG_LIVE_ITERATOR_STATUS_END:
+            /*
+             * A session returned `_END`. Other sessions may still
+             * be active so we override the status and continue
+             * looping if needed.
+             */
             break;
         default:
             goto end;
@@ -696,7 +724,6 @@ static int live_get_msg_ts_ns(struct lttng_live_stream_iterator *stream_iter,
                               struct lttng_live_msg_iter *lttng_live_msg_iter,
                               const bt_message *msg, int64_t last_msg_ts_ns, int64_t *ts_ns)
 {
-    const bt_clock_class *clock_class = NULL;
     const bt_clock_snapshot *clock_snapshot = NULL;
     int ret = 0;
     bt_logging_level log_level = lttng_live_msg_iter->log_level;
@@ -711,37 +738,19 @@ static int live_get_msg_ts_ns(struct lttng_live_stream_iterator *stream_iter,
 
     switch (bt_message_get_type(msg)) {
     case BT_MESSAGE_TYPE_EVENT:
-        clock_class = bt_message_event_borrow_stream_class_default_clock_class_const(msg);
-        BT_ASSERT_DBG(clock_class);
-
         clock_snapshot = bt_message_event_borrow_default_clock_snapshot_const(msg);
         break;
     case BT_MESSAGE_TYPE_PACKET_BEGINNING:
-        clock_class =
-            bt_message_packet_beginning_borrow_stream_class_default_clock_class_const(msg);
-        BT_ASSERT(clock_class);
-
         clock_snapshot = bt_message_packet_beginning_borrow_default_clock_snapshot_const(msg);
         break;
     case BT_MESSAGE_TYPE_PACKET_END:
-        clock_class = bt_message_packet_end_borrow_stream_class_default_clock_class_const(msg);
-        BT_ASSERT(clock_class);
-
         clock_snapshot = bt_message_packet_end_borrow_default_clock_snapshot_const(msg);
         break;
     case BT_MESSAGE_TYPE_DISCARDED_EVENTS:
-        clock_class =
-            bt_message_discarded_events_borrow_stream_class_default_clock_class_const(msg);
-        BT_ASSERT(clock_class);
-
         clock_snapshot =
             bt_message_discarded_events_borrow_beginning_default_clock_snapshot_const(msg);
         break;
     case BT_MESSAGE_TYPE_DISCARDED_PACKETS:
-        clock_class =
-            bt_message_discarded_packets_borrow_stream_class_default_clock_class_const(msg);
-        BT_ASSERT(clock_class);
-
         clock_snapshot =
             bt_message_discarded_packets_borrow_beginning_default_clock_snapshot_const(msg);
         break;
@@ -755,9 +764,6 @@ static int live_get_msg_ts_ns(struct lttng_live_stream_iterator *stream_iter,
         goto end;
     }
 
-    clock_class = bt_clock_snapshot_borrow_clock_class_const(clock_snapshot);
-    BT_ASSERT_DBG(clock_class);
-
     ret = bt_clock_snapshot_get_ns_from_origin(clock_snapshot, ts_ns);
     if (ret) {
         BT_COMP_LOGE_APPEND_CAUSE(self_comp,
@@ -1497,7 +1503,6 @@ static inline void put_messages(bt_message_array_const msgs, uint64_t count)
     }
 }
 
-BT_HIDDEN
 bt_message_iterator_class_next_method_status
 lttng_live_msg_iter_next(bt_self_message_iterator *self_msg_it, bt_message_array_const msgs,
                          uint64_t capacity, uint64_t *count)
@@ -1774,7 +1779,6 @@ end:
     return lttng_live_msg_iter;
 }
 
-BT_HIDDEN
 bt_message_iterator_class_initialize_method_status
 lttng_live_msg_iter_init(bt_self_message_iterator *self_msg_it,
                          bt_self_message_iterator_configuration *config,
@@ -2018,7 +2022,6 @@ end:
     return status;
 }
 
-BT_HIDDEN
 bt_component_class_query_method_status lttng_live_query(bt_self_component_class_source *comp_class,
                                                         bt_private_query_executor *priv_query_exec,
                                                         const char *object, const bt_value *params,
@@ -2057,7 +2060,6 @@ static void lttng_live_component_destroy_data(struct lttng_live_component *lttng
     g_free(lttng_live);
 }
 
-BT_HIDDEN
 void lttng_live_component_finalize(bt_self_component_source *component)
 {
     lttng_live_component *data = (lttng_live_component *) bt_self_component_get_data(
@@ -2169,7 +2171,6 @@ end:
     return status;
 }
 
-BT_HIDDEN
 bt_component_class_initialize_method_status
 lttng_live_component_init(bt_self_component_source *self_comp_src,
                           bt_self_component_source_configuration *config, const bt_value *params,
This page took 0.026499 seconds and 4 git commands to generate.