src.ctf.lttng-live: make lttng_live_trace::trace a bt2::Trace::Shared
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 6 Dec 2023 17:29:01 +0000 (17:29 +0000)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Apr 2024 17:57:53 +0000 (13:57 -0400)
Use the C++ wrapper to hold the reference to the trace.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Iadfe9add10e5a6e3112cc0626b2ece868a013b40
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8416
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12352
Tested-by: jenkins <jenkins@lttng.org>
src/plugins/ctf/lttng-live/data-stream.cpp
src/plugins/ctf/lttng-live/lttng-live.cpp
src/plugins/ctf/lttng-live/lttng-live.hpp
src/plugins/ctf/lttng-live/metadata.cpp

index 3e7386f45fd95665455075c839734875eb19fd2e..cf49b7e39a84839646ebadcde026d2bd2e585d68 100644 (file)
@@ -78,11 +78,12 @@ static bt_stream *medop_borrow_stream(bt_stream_class *stream_class, int64_t str
              * LTTng. In these cases, use the viewer_stream_id that
              * is unique for a live viewer session.
              */
-            lttng_live_stream->stream = bt_stream_create_with_id(
-                stream_class, lttng_live_stream->trace->trace, lttng_live_stream->viewer_stream_id);
+            lttng_live_stream->stream =
+                bt_stream_create_with_id(stream_class, lttng_live_stream->trace->trace->libObjPtr(),
+                                         lttng_live_stream->viewer_stream_id);
         } else {
             lttng_live_stream->stream = bt_stream_create_with_id(
-                stream_class, lttng_live_stream->trace->trace, (uint64_t) stream_id);
+                stream_class, lttng_live_stream->trace->trace->libObjPtr(), (uint64_t) stream_id);
         }
 
         if (!lttng_live_stream->stream) {
index 9bfc2f6f9c66ff2b4040b8867d76e82d0652af9a..7d687b3ebf1574b30d696c492f163b89d27e2170 100644 (file)
@@ -93,8 +93,6 @@ static void lttng_live_destroy_trace(struct lttng_live_trace *trace)
     BT_ASSERT(trace->stream_iterators);
     g_ptr_array_free(trace->stream_iterators, TRUE);
 
-    BT_TRACE_PUT_REF_AND_RESET(trace->trace);
-
     lttng_live_metadata_fini(trace);
     delete trace;
 }
@@ -108,7 +106,6 @@ static struct lttng_live_trace *lttng_live_create_trace(struct lttng_live_sessio
     lttng_live_trace *trace = new lttng_live_trace {session->logger};
     trace->session = session;
     trace->id = trace_id;
-    trace->trace = NULL;
     trace->stream_iterators =
         g_ptr_array_new_with_free_func((GDestroyNotify) lttng_live_stream_iterator_destroy);
     BT_ASSERT(trace->stream_iterators);
index d6c01ad3e88fa29d9da42fc8a68d33c7140f331b..610defd91e7a5fb345e79ee9f6a8de62c27e9f59 100644 (file)
@@ -190,8 +190,7 @@ struct lttng_live_trace
     /* ctf trace ID within the session. */
     uint64_t id = 0;
 
-    /* Owned by this. */
-    bt_trace *trace = nullptr;
+    bt2::Trace::Shared trace;
 
     bt2::TraceClass::Shared trace_class;
 
index 49bdf6888c8bd4a9a25614d9445a26e94dcc273e..7f4bc76813970cd2447f80aa876dc2da3b05d56a 100644 (file)
@@ -209,12 +209,12 @@ enum lttng_live_iterator_status lttng_live_metadata_update(struct lttng_live_tra
                 ctf_metadata_decoder_borrow_ctf_trace_class(metadata->decoder.get());
 
             trace->trace_class = ctf_metadata_decoder_get_ir_trace_class(metadata->decoder.get());
-            trace->trace = bt_trace_create(trace->trace_class->libObjPtr());
+            trace->trace = trace->trace_class->instantiate();
             if (!trace->trace) {
                 BT_CPPLOGE_APPEND_CAUSE_SPEC(metadata->logger, "Failed to create bt_trace");
                 goto error;
             }
-            if (ctf_trace_class_configure_ir_trace(tc, trace->trace)) {
+            if (ctf_trace_class_configure_ir_trace(tc, trace->trace->libObjPtr())) {
                 BT_CPPLOGE_APPEND_CAUSE_SPEC(metadata->logger,
                                              "Failed to configure ctf trace class");
                 goto error;
This page took 0.027989 seconds and 4 git commands to generate.