src.ctf.lttng-live: make lttng_live_trace::trace_class a bt2::TraceClass::Shared
authorSimon Marchi <simon.marchi@efficios.com>
Sun, 19 Jun 2022 03:09:57 +0000 (23:09 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 23 Aug 2022 16:06:16 +0000 (12:06 -0400)
Use the C++ wrapper to hold the reference to the trace class.  Wrap it
in an optional, since it's not assigned at creation.

Note that the existing comment said it is a weak reference, but the code
shows otherwise.

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

index 03055c030dc96a0b8d08b9a8c99bdaa508d9d087..0e0d4a0c4668cf89e8af83903da4c4c8eadc6aac 100644 (file)
@@ -152,7 +152,6 @@ static void lttng_live_destroy_trace(struct lttng_live_trace *trace)
     g_ptr_array_free(trace->stream_iterators, TRUE);
 
     BT_TRACE_PUT_REF_AND_RESET(trace->trace);
-    BT_TRACE_CLASS_PUT_REF_AND_RESET(trace->trace_class);
 
     lttng_live_metadata_fini(trace);
     delete trace;
@@ -170,7 +169,6 @@ static struct lttng_live_trace *lttng_live_create_trace(struct lttng_live_sessio
     lttng_live_trace *trace = new lttng_live_trace {logCfg};
     trace->session = session;
     trace->id = trace_id;
-    trace->trace_class = NULL;
     trace->trace = NULL;
     trace->stream_iterators =
         g_ptr_array_new_with_free_func((GDestroyNotify) lttng_live_stream_iterator_destroy);
index 2be5f2b7715f6e8b746c20df8a043ad286f5d666..329393fbd453a50628645af0be0963b4ad6c190d 100644 (file)
@@ -175,8 +175,7 @@ struct lttng_live_trace
     /* Owned by this. */
     bt_trace *trace = nullptr;
 
-    /* Weak reference. */
-    bt_trace_class *trace_class = nullptr;
+    nonstd::optional<bt2::TraceClass::Shared> trace_class;
 
     struct lttng_live_metadata *metadata = nullptr;
 
index e9c861a8c2542458f6f42b9bc210dfc20734f5c0..be0db63d03c358c12fa80046376302f0ab6e839a 100644 (file)
@@ -217,10 +217,8 @@ enum lttng_live_iterator_status lttng_live_metadata_update(struct lttng_live_tra
             struct ctf_trace_class *tc =
                 ctf_metadata_decoder_borrow_ctf_trace_class(metadata->decoder.get());
 
-            trace->trace_class = ctf_metadata_decoder_get_ir_trace_class(metadata->decoder.get())
-                                     ->release()
-                                     .libObjPtr();
-            trace->trace = bt_trace_create(trace->trace_class);
+            trace->trace_class = ctf_metadata_decoder_get_ir_trace_class(metadata->decoder.get());
+            trace->trace = bt_trace_create((*trace->trace_class)->libObjPtr());
             if (!trace->trace) {
                 BT_CLOGE_APPEND_CAUSE("Failed to create bt_trace");
                 goto error;
@@ -229,11 +227,12 @@ enum lttng_live_iterator_status lttng_live_metadata_update(struct lttng_live_tra
                 BT_CLOGE_APPEND_CAUSE("Failed to configure ctf trace class");
                 goto error;
             }
-            if (!stream_classes_all_have_default_clock_class(trace->trace_class, logCfg)) {
+            if (!stream_classes_all_have_default_clock_class((*trace->trace_class)->libObjPtr(),
+                                                             logCfg)) {
                 /* Error logged in function. */
                 goto error;
             }
-            trace->clock_class = borrow_any_clock_class(trace->trace_class);
+            trace->clock_class = borrow_any_clock_class((*trace->trace_class)->libObjPtr());
         }
 
         /* The metadata was updated succesfully. */
This page took 0.026763 seconds and 5 git commands to generate.