plugins/ctf/common/metadata: logging: standardize in parser and lexer
[babeltrace.git] / plugins / ctf / lttng-live / metadata.c
index 7c8ce4dddb49498fdd8f82a5a34999c5ea3b74ab..1adc81c1553bd893319738aae900c54e1b5c4534 100644 (file)
@@ -23,6 +23,9 @@
  * SOFTWARE.
  */
 
+#define BT_LOG_TAG "PLUGIN-CTF-LTTNG-LIVE-SRC-METADATA"
+#include "logging.h"
+
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -32,8 +35,6 @@
 #include <babeltrace/compat/memstream-internal.h>
 #include <babeltrace/graph/graph.h>
 
-#define BT_LOG_TAG "PLUGIN-CTF-LTTNG-LIVE-METADATA"
-
 #include "metadata.h"
 #include "../common/metadata/decoder.h"
 
@@ -116,6 +117,10 @@ enum bt_ctf_lttng_live_iterator_status lttng_live_metadata_update(
                goto end;
        }
 
+       if (!metadata->trace) {
+               trace->new_metadata_needed = false;
+       }
+
        if (!trace->new_metadata_needed) {
                goto end;
        }
@@ -155,9 +160,10 @@ enum bt_ctf_lttng_live_iterator_status lttng_live_metadata_update(
                         * the data streams are done.
                         */
                        lttng_live_unref_trace(metadata->trace);
+                       metadata->trace = NULL;
                }
                if (errno == EINTR) {
-                       if (bt_graph_is_canceled(session->lttng_live->graph)) {
+                       if (lttng_live_is_canceled(session->lttng_live)) {
                                status = BT_CTF_LTTNG_LIVE_ITERATOR_STATUS_AGAIN;
                                goto end;
                        }
@@ -179,10 +185,6 @@ enum bt_ctf_lttng_live_iterator_status lttng_live_metadata_update(
                goto end;
        }
 
-       if (babeltrace_debug) {
-               // yydebug = 1;
-       }
-
        fp = bt_fmemopen(metadata_buf, len_read, "rb");
        if (!fp) {
                BT_LOGE("Cannot memory-open metadata buffer: %s",
@@ -222,16 +224,19 @@ end:
                        BT_LOGE("Error on fclose");
                }
        }
+       free(metadata_buf);
        return status;
 }
 
 BT_HIDDEN
 int lttng_live_metadata_create_stream(struct lttng_live_session *session,
                uint64_t ctf_trace_id,
-               uint64_t stream_id)
+               uint64_t stream_id,
+               const char *trace_name)
 {
        struct lttng_live_metadata *metadata = NULL;
        struct lttng_live_trace *trace;
+       const char *match;
 
        metadata = g_new0(struct lttng_live_metadata, 1);
        if (!metadata) {
@@ -239,9 +244,12 @@ int lttng_live_metadata_create_stream(struct lttng_live_session *session,
        }
        metadata->stream_id = stream_id;
        //TODO: add clock offset option
-       //TODO: add (preferably unique) trace's name
-       metadata->decoder = ctf_metadata_decoder_create(stderr, 0,
-               "lttng-live");
+       match = strstr(trace_name, session->session_name->str);
+       if (!match) {
+               goto error;
+       }
+       metadata->decoder = ctf_metadata_decoder_create(0,
+               match);
        if (!metadata->decoder) {
                goto error;
        }
@@ -272,7 +280,6 @@ void lttng_live_metadata_fini(struct lttng_live_trace *trace)
        }
        ctf_metadata_decoder_destroy(metadata->decoder);
        trace->metadata = NULL;
-       lttng_live_unref_trace(trace);
        if (!metadata->closed) {
                lttng_live_unref_trace(metadata->trace);
        }
This page took 0.023872 seconds and 4 git commands to generate.