src.ctf.lttng-live: make `lttng_live_attach_session()` return status
[babeltrace.git] / src / plugins / ctf / lttng-live / lttng-live.h
index e5d08613d560192bfb2584684521a0dfcaa9a3fe..511c0c486793e9d98ecd774ad6b223847bac8ec2 100644 (file)
@@ -119,6 +119,8 @@ struct lttng_live_stream_iterator {
 
        /* Owned by this. */
        GString *name;
+
+       bool has_stream_hung_up;
 };
 
 struct lttng_live_metadata {
@@ -131,8 +133,6 @@ struct lttng_live_metadata {
        uint64_t stream_id;
        /* Weak reference. */
        struct ctf_metadata_decoder *decoder;
-
-       bool closed;
 };
 
 struct lttng_live_trace {
@@ -187,7 +187,6 @@ struct lttng_live_session {
 };
 
 enum session_not_found_action {
-       SESSION_NOT_FOUND_ACTION_UNKNOWN,
        SESSION_NOT_FOUND_ACTION_CONTINUE,
        SESSION_NOT_FOUND_ACTION_FAIL,
        SESSION_NOT_FOUND_ACTION_END,
@@ -258,15 +257,16 @@ enum lttng_live_iterator_status {
        LTTNG_LIVE_ITERATOR_STATUS_UNSUPPORTED = -4,
 };
 
-bt_component_class_init_method_status lttng_live_component_init(
+bt_component_class_initialize_method_status lttng_live_component_init(
                bt_self_component_source *self_comp,
+               bt_self_component_source_configuration *config,
                const bt_value *params, void *init_method_data);
 
 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,
-               const bt_value **result);
+               void *method_data, const bt_value **result);
 
 void lttng_live_component_finalize(bt_self_component_source *component);
 
@@ -275,15 +275,24 @@ bt_component_class_message_iterator_next_method_status lttng_live_msg_iter_next(
                bt_message_array_const msgs, uint64_t capacity,
                uint64_t *count);
 
-bt_component_class_message_iterator_init_method_status lttng_live_msg_iter_init(
+bt_component_class_message_iterator_initialize_method_status lttng_live_msg_iter_init(
                bt_self_message_iterator *self_msg_it,
+               bt_self_message_iterator_configuration *config,
                bt_self_component_source *self_comp,
                bt_self_component_port_output *self_port);
 
 void lttng_live_msg_iter_finalize(bt_self_message_iterator *it);
 
 int lttng_live_create_viewer_session(struct lttng_live_msg_iter *lttng_live_msg_iter);
-int lttng_live_attach_session(struct lttng_live_session *session);
+
+enum lttng_live_attach_session_status {
+       LTTNG_LIVE_ATTACH_SESSION_STATUS_OK     = 0,
+       LTTNG_LIVE_ATTACH_SESSION_STATUS_ERROR  = -2,
+};
+
+enum lttng_live_attach_session_status lttng_live_attach_session(
+               struct lttng_live_session *session);
+
 int lttng_live_detach_session(struct lttng_live_session *session);
 enum lttng_live_iterator_status lttng_live_get_new_streams(
                struct lttng_live_session *session);
@@ -293,8 +302,30 @@ int lttng_live_add_session(struct lttng_live_msg_iter *lttng_live_msg_iter,
                const char *hostname,
                const char *session_name);
 
-ssize_t lttng_live_get_one_metadata_packet(struct lttng_live_trace *trace,
-               FILE *fp);
+enum lttng_live_get_one_metadata_status {
+       /* The end of the metadata stream was reached. */
+       LTTNG_LIVE_GET_ONE_METADATA_STATUS_END      = 1,
+       /* One metadata packet was received and written to file. */
+       LTTNG_LIVE_GET_ONE_METADATA_STATUS_OK       = 0,
+       /* The metadata stream was not found on the relay. */
+       LTTNG_LIVE_GET_ONE_METADATA_STATUS_CLOSED   = -1,
+       /*
+        * A critical error occurred when contacting the relay or while
+        * handling its response.
+        */
+       LTTNG_LIVE_GET_ONE_METADATA_STATUS_ERROR    = -2,
+};
+
+/*
+ * lttng_live_get_one_metadata_packet() asks the Relay Daemon for new metadata.
+ * If new metadata is received, the function writes it to the provided file
+ * handle and updates the reply_len output parameter. This function should be
+ * called in loop until _END status is received to ensure all metadata is
+ * written to the file.
+ */
+enum lttng_live_get_one_metadata_status lttng_live_get_one_metadata_packet(
+               struct lttng_live_trace *trace, FILE *fp, size_t *reply_len);
+
 enum lttng_live_iterator_status lttng_live_get_next_index(
                struct lttng_live_msg_iter *lttng_live_msg_iter,
                struct lttng_live_stream_iterator *stream,
This page took 0.02532 seconds and 4 git commands to generate.