ctf: use self component / message iterator C++ wrappers throughout
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 9 Sep 2024 17:27:42 +0000 (13:27 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 10 Sep 2024 17:57:58 +0000 (13:57 -0400)
Use `bt2::SelfComponent`, `bt2::SelfSourceComponent`,
`bt2::SelfSinkComponent` and `bt2::SelfMessageIterator` for function
parameters and fields throughout `src/plugins/ctf` instead of raw
pointers.

Don't try to adapt the code too much to use the wrappers yet.

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

index 6b0c88da9b0c59e0b127b36e84f27c4e5f6ce3e4..c580b39f2ef5b88acdf50020726b3a675efa16b0 100644 (file)
@@ -10,6 +10,7 @@
 #include <babeltrace2/babeltrace.h>
 
 #include "common/assert.h"
+#include "cpp-common/bt2/wrap.hpp"
 #include "cpp-common/vendor/fmt/format.h"
 #include "ctfser/ctfser.h"
 
@@ -136,9 +137,8 @@ bt_component_class_initialize_method_status ctf_fs_sink_init(bt_self_component_s
         bt_component_class_initialize_method_status status;
         bt_self_component_add_port_status add_port_status;
         struct fs_sink_comp *fs_sink = NULL;
-        bt_self_component *self_comp = bt_self_component_sink_as_self_component(self_comp_sink);
 
-        fs_sink = new fs_sink_comp {bt2::SelfSinkComponent {self_comp_sink}};
+        fs_sink = new fs_sink_comp {bt2::wrap(self_comp_sink)};
         fs_sink->output_dir_path = g_string_new(NULL);
         status = configure_component(fs_sink, params);
         if (status != BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK) {
@@ -177,7 +177,8 @@ bt_component_class_initialize_method_status ctf_fs_sink_init(bt_self_component_s
             goto end;
         }
 
-        bt_self_component_set_data(self_comp, fs_sink);
+        bt_self_component_set_data(bt_self_component_sink_as_self_component(self_comp_sink),
+                                   fs_sink);
 
 end:
         if (status != BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK) {
index 97e1f34ef4a28c9c34ba8ac67a9bf00a00429c6d..0b15728107f710bd271ab2b84199aed108972cdf 100644 (file)
@@ -121,10 +121,10 @@ static void instantiateMsgIter(ctf_fs_msg_iter_data *msg_iter_data)
     ctf_fs_ds_file_group *ds_file_group = msg_iter_data->port_data->ds_file_group;
 
     Medium::UP medium = bt2s::make_unique<fs::Medium>(ds_file_group->index, msg_iter_data->logger);
-    msg_iter_data->msgIter.emplace(
-        bt2::wrap(msg_iter_data->self_msg_iter), *ds_file_group->ctf_fs_trace->cls(),
-        ds_file_group->ctf_fs_trace->metadataStreamUuid(), *ds_file_group->stream,
-        std::move(medium), msg_iter_data->port_data->ctf_fs->quirks, msg_iter_data->logger);
+    msg_iter_data->msgIter.emplace(msg_iter_data->selfMsgIter, *ds_file_group->ctf_fs_trace->cls(),
+                                   ds_file_group->ctf_fs_trace->metadataStreamUuid(),
+                                   *ds_file_group->stream, std::move(medium),
+                                   msg_iter_data->port_data->ctf_fs->quirks, msg_iter_data->logger);
 }
 
 bt_message_iterator_class_seek_beginning_method_status
@@ -162,7 +162,7 @@ ctf_fs_iterator_init(bt_self_message_iterator *self_msg_iter,
             bt_self_component_port_output_as_self_component_port(self_port));
         BT_ASSERT(port_data);
 
-        auto msg_iter_data = bt2s::make_unique<ctf_fs_msg_iter_data>(self_msg_iter);
+        auto msg_iter_data = bt2s::make_unique<ctf_fs_msg_iter_data>(bt2::wrap(self_msg_iter));
         msg_iter_data->port_data = port_data;
 
         instantiateMsgIter(msg_iter_data.get());
@@ -235,7 +235,7 @@ std::string ctf_fs_make_port_name(ctf_fs_ds_file_group *ds_file_group)
 
 static int create_one_port_for_trace(struct ctf_fs_component *ctf_fs,
                                      struct ctf_fs_ds_file_group *ds_file_group,
-                                     bt_self_component_source *self_comp_src)
+                                     const bt2::SelfSourceComponent selfSrcComp)
 {
     const auto port_name = ctf_fs_make_port_name(ds_file_group);
     auto port_data = bt2s::make_unique<ctf_fs_port_data>();
@@ -245,7 +245,7 @@ static int create_one_port_for_trace(struct ctf_fs_component *ctf_fs,
     port_data->ctf_fs = ctf_fs;
     port_data->ds_file_group = ds_file_group;
 
-    int ret = bt_self_component_source_add_output_port(self_comp_src, port_name.c_str(),
+    int ret = bt_self_component_source_add_output_port(selfSrcComp.libObjPtr(), port_name.c_str(),
                                                        port_data.get(), NULL);
     if (ret) {
         return ret;
@@ -257,11 +257,11 @@ static int create_one_port_for_trace(struct ctf_fs_component *ctf_fs,
 
 static int create_ports_for_trace(struct ctf_fs_component *ctf_fs,
                                   struct ctf_fs_trace *ctf_fs_trace,
-                                  bt_self_component_source *self_comp_src)
+                                  const bt2::SelfSourceComponent selfSrcComp)
 {
     /* Create one output port for each stream file group */
     for (const auto& ds_file_group : ctf_fs_trace->ds_file_groups) {
-        int ret = create_one_port_for_trace(ctf_fs, ds_file_group.get(), self_comp_src);
+        int ret = create_one_port_for_trace(ctf_fs, ds_file_group.get(), selfSrcComp);
         if (ret) {
             BT_CPPLOGE_APPEND_CAUSE_SPEC(ctf_fs->logger, "Cannot create output port.");
             return ret;
@@ -490,9 +490,10 @@ static void set_trace_name(const bt2::Trace trace, const char *name_suffix)
     trace.name(name);
 }
 
-static ctf_fs_trace::UP ctf_fs_trace_create(const char *path, const char *name,
-                                            const ctf::src::ClkClsCfg& clkClsCfg,
-                                            bt_self_component *selfComp, const bt2c::Logger& logger)
+static ctf_fs_trace::UP
+ctf_fs_trace_create(const char *path, const char *name, const ctf::src::ClkClsCfg& clkClsCfg,
+                    const bt2::OptionalBorrowedObject<bt2::SelfComponent> selfComp,
+                    const bt2c::Logger& logger)
 {
     auto ctf_fs_trace = bt2s::make_unique<struct ctf_fs_trace>(clkClsCfg, selfComp, logger);
     const auto metadataPath = fmt::format("{}" G_DIR_SEPARATOR_S CTF_FS_METADATA_FILENAME, path);
@@ -505,9 +506,9 @@ static ctf_fs_trace::UP ctf_fs_trace_create(const char *path, const char *name,
     if (ctf_fs_trace->cls()->libCls()) {
         bt2::TraceClass traceCls = *ctf_fs_trace->cls()->libCls();
         ctf_fs_trace->trace = traceCls.instantiate();
-        ctf_trace_class_configure_ir_trace(*ctf_fs_trace->cls(), *ctf_fs_trace->trace,
-                                           bt_self_component_get_graph_mip_version(selfComp),
-                                           logger);
+        ctf_trace_class_configure_ir_trace(
+            *ctf_fs_trace->cls(), *ctf_fs_trace->trace,
+            bt_self_component_get_graph_mip_version(selfComp->libObjPtr()), logger);
         set_trace_name(*ctf_fs_trace->trace, name);
     }
 
@@ -527,11 +528,10 @@ static int path_is_ctf_trace(const char *path)
 
 /* Helper for ctf_fs_component_create_ctf_fs_trace, to handle a single path. */
 
-static int ctf_fs_component_create_ctf_fs_trace_one_path(struct ctf_fs_component *ctf_fs,
-                                                         const char *path_param,
-                                                         const char *trace_name,
-                                                         std::vector<ctf_fs_trace::UP>& traces,
-                                                         bt_self_component *selfComp)
+static int ctf_fs_component_create_ctf_fs_trace_one_path(
+    struct ctf_fs_component *ctf_fs, const char *path_param, const char *trace_name,
+    std::vector<ctf_fs_trace::UP>& traces,
+    const bt2::OptionalBorrowedObject<bt2::SelfComponent> selfComp)
 {
     bt2c::GStringUP norm_path {bt_common_normalize_path(path_param, NULL)};
     if (!norm_path) {
@@ -1267,9 +1267,9 @@ static bool compare_ds_file_groups_by_first_path(const ctf_fs_ds_file_group::UP&
     return first_ds_file_info_a.path < first_ds_file_info_b.path;
 }
 
-int ctf_fs_component_create_ctf_fs_trace(struct ctf_fs_component *ctf_fs,
-                                         const bt2::ConstArrayValue pathsValue,
-                                         const char *traceName, bt_self_component *selfComp)
+int ctf_fs_component_create_ctf_fs_trace(
+    struct ctf_fs_component *ctf_fs, const bt2::ConstArrayValue pathsValue, const char *traceName,
+    const bt2::OptionalBorrowedObject<bt2::SelfComponent> selfComp)
 {
     std::vector<std::string> paths;
 
@@ -1467,22 +1467,22 @@ ctf::src::fs::Parameters read_src_fs_parameters(const bt2::ConstMapValue params,
 }
 
 static ctf_fs_component::UP ctf_fs_create(const bt2::ConstMapValue params,
-                                          bt_self_component_source *self_comp_src)
+                                          const bt2::SelfSourceComponent selfSrcComp)
 {
-    bt_self_component *self_comp = bt_self_component_source_as_self_component(self_comp_src);
-    const bt2c::Logger logger {bt2::SelfSourceComponent {self_comp_src}, "PLUGIN/SRC.CTF.FS/COMP"};
+    const bt2c::Logger logger {selfSrcComp, "PLUGIN/SRC.CTF.FS/COMP"};
     const auto parameters = read_src_fs_parameters(params, logger);
     auto ctf_fs = bt2s::make_unique<ctf_fs_component>(parameters.clkClsCfg, logger);
 
-    if (ctf_fs_component_create_ctf_fs_trace(
-            ctf_fs.get(), parameters.inputs,
-            parameters.traceName ? parameters.traceName->c_str() : nullptr, self_comp)) {
+    if (ctf_fs_component_create_ctf_fs_trace(ctf_fs.get(), parameters.inputs,
+                                             parameters.traceName ? parameters.traceName->c_str() :
+                                                                    nullptr,
+                                             static_cast<bt2::SelfComponent>(selfSrcComp))) {
         return nullptr;
     }
 
     create_streams_for_trace(ctf_fs->trace.get());
 
-    if (create_ports_for_trace(ctf_fs.get(), ctf_fs->trace.get(), self_comp_src)) {
+    if (create_ports_for_trace(ctf_fs.get(), ctf_fs->trace.get(), selfSrcComp)) {
         return nullptr;
     }
 
@@ -1494,7 +1494,8 @@ bt_component_class_initialize_method_status ctf_fs_init(bt_self_component_source
                                                         const bt_value *params, void *)
 {
     try {
-        ctf_fs_component::UP ctf_fs = ctf_fs_create(bt2::ConstMapValue {params}, self_comp_src);
+        ctf_fs_component::UP ctf_fs =
+            ctf_fs_create(bt2::ConstMapValue {params}, bt2::wrap(self_comp_src));
         if (!ctf_fs) {
             return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
         }
index 37da1835c11bbb1f356910a8e8c73d9a59b13b9f..35ffe3e5dbffa23cc740ccf0e224140f82f32f16 100644 (file)
@@ -107,14 +107,12 @@ struct ctf_fs_msg_iter_data
 {
     using UP = std::unique_ptr<ctf_fs_msg_iter_data>;
 
-    explicit ctf_fs_msg_iter_data(bt_self_message_iterator *selfMsgIter) :
-        self_msg_iter {selfMsgIter},
-        logger {bt2::SelfMessageIterator {self_msg_iter}, "PLUGIN/SRC.CTF.FS/MSG-ITER"}
+    explicit ctf_fs_msg_iter_data(const bt2::SelfMessageIterator selfMsgIterParam) :
+        selfMsgIter {selfMsgIterParam}, logger {selfMsgIter, "PLUGIN/SRC.CTF.FS/MSG-ITER"}
     {
     }
 
-    /* Weak */
-    bt_self_message_iterator *self_msg_iter = nullptr;
+    bt2::SelfMessageIterator selfMsgIter;
 
     bt2c::Logger logger;
 
@@ -165,14 +163,11 @@ ctf_fs_iterator_seek_beginning(bt_self_message_iterator *message_iterator);
  * `paths_value` must be an array of strings,
  *
  * The created `struct ctf_fs_trace` is assigned to `ctf_fs->trace`.
- *
- * `self_comp` and `self_comp_class` are used for logging, only one of them
- * should be set.
  */
 
 int ctf_fs_component_create_ctf_fs_trace(struct ctf_fs_component *ctf_fs,
                                          bt2::ConstArrayValue pathsValue, const char *traceName,
-                                         bt_self_component *selfComp);
+                                         bt2::OptionalBorrowedObject<bt2::SelfComponent> selfComp);
 
 namespace ctf {
 namespace src {
index bab69e26c375e94f7eda928f895ec12172eef33d..c1523a9685f89cf21c8c5a6f569c1396457fdf67 100644 (file)
@@ -11,6 +11,9 @@
 
 #include <babeltrace2/babeltrace.h>
 
+#include "cpp-common/bt2/optional-borrowed-object.hpp"
+#include "cpp-common/bt2/self-component-port.hpp"
+
 namespace bt2c {
 
 class Logger;
@@ -21,7 +24,8 @@ class Logger;
 
 #define CTF_FS_METADATA_FILENAME "metadata"
 
-int ctf_fs_metadata_set_trace_class(bt_self_component *self_comp, struct ctf_fs_trace *ctf_fs_trace,
+int ctf_fs_metadata_set_trace_class(bt2::OptionalBorrowedObject<bt2::SelfComponent> selfComp,
+                                    struct ctf_fs_trace *ctf_fs_trace,
                                     const ctf::src::ClkClsCfg& clkClsCfg);
 
 FILE *ctf_fs_metadata_open_file(const char *trace_path, const bt2c::Logger& logger);
index 206453200990557afad6a695c86081d532bdd54d..ee90eb20b438c14146d070867d291a26b68f9948 100644 (file)
@@ -145,7 +145,7 @@ bt2::Value::Shared trace_infos_query(const bt2::ConstMapValue params, const bt2c
 
     if (ctf_fs_component_create_ctf_fs_trace(
             &ctf_fs, parameters.inputs,
-            parameters.traceName ? parameters.traceName->c_str() : nullptr, nullptr)) {
+            parameters.traceName ? parameters.traceName->c_str() : nullptr, {})) {
         BT_CPPLOGE_APPEND_CAUSE_AND_THROW_SPEC(logger, bt2::Error, "Failed to create trace");
     }
 
index b385df90bcda9a128d80eecc4cb22da2679571de..812628b4918c88d9bb1cc92e7d6a7d5620efb327 100644 (file)
@@ -13,7 +13,6 @@
 
 #include "common/assert.h"
 #include "compat/mman.h" /* IWYU pragma: keep  */
-#include "cpp-common/bt2/wrap.hpp"
 #include "cpp-common/bt2s/make-unique.hpp"
 #include "cpp-common/vendor/fmt/format.h"
 
@@ -139,7 +138,7 @@ lttng_live_stream_iterator_create_msg_iter(lttng_live_stream_iterator *liveStrea
     liveStreamIter->stream->name(liveStreamIter->name);
 
     auto medium = bt2s::make_unique<ctf::src::live::CtfLiveMedium>(*liveStreamIter);
-    liveStreamIter->msg_iter.emplace(bt2::wrap(liveMsgIter->self_msg_iter), *ctfTc,
+    liveStreamIter->msg_iter.emplace(liveMsgIter->selfMsgIter, *ctfTc,
                                      liveStreamIter->trace->metadata->metadataStreamUuid(),
                                      *liveStreamIter->stream, std::move(medium),
                                      ctf::src::MsgIterQuirks {}, liveStreamIter->logger);
@@ -147,7 +146,7 @@ lttng_live_stream_iterator_create_msg_iter(lttng_live_stream_iterator *liveStrea
 }
 
 enum lttng_live_iterator_status lttng_live_lazy_msg_init(struct lttng_live_session *session,
-                                                         bt_self_message_iterator *self_msg_iter)
+                                                         const bt2::SelfMessageIterator selfMsgIter)
 {
     if (!session->lazy_stream_msg_init) {
         return LTTNG_LIVE_ITERATOR_STATUS_OK;
@@ -156,7 +155,7 @@ enum lttng_live_iterator_status lttng_live_lazy_msg_init(struct lttng_live_sessi
     BT_CPPLOGD_SPEC(session->logger,
                     "Lazily initializing self message iterator for live session: "
                     "session-id={}, self-msg-iter-addr={}",
-                    session->id, fmt::ptr(self_msg_iter));
+                    session->id, fmt::ptr(selfMsgIter.libObjPtr()));
 
     for (lttng_live_trace::UP& trace : session->traces) {
         for (lttng_live_stream_iterator::UP& stream_iter : trace->stream_iterators) {
@@ -169,7 +168,7 @@ enum lttng_live_iterator_status lttng_live_lazy_msg_init(struct lttng_live_sessi
                             "Creating CTF message iterator: session-id={}, ctf-tc-addr={}, "
                             "stream-iter-name={}, self-msg-iter-addr={}",
                             session->id, fmt::ptr(ctfTraceCls), stream_iter->name.c_str(),
-                            fmt::ptr(self_msg_iter));
+                            fmt::ptr(selfMsgIter.libObjPtr()));
         }
     }
 
index 702454e77981a739f9143e22fce675249f958e5b..5370b8675327c3bbfa48acfc008a3120a94daad4 100644 (file)
@@ -12,7 +12,7 @@
 #include "lttng-live.hpp"
 
 enum lttng_live_iterator_status lttng_live_lazy_msg_init(struct lttng_live_session *session,
-                                                         bt_self_message_iterator *self_msg_iter);
+                                                         bt2::SelfMessageIterator selfMsgIter);
 
 struct lttng_live_stream_iterator *
 lttng_live_stream_iterator_create(struct lttng_live_session *session, uint64_t ctf_trace_id,
index 0f2d6b5f48f7b979f09f055685bfe07bf938f32b..efe51e32c8e88a1d0b68513b00494f63997c9e8a 100644 (file)
@@ -62,7 +62,7 @@ bool lttng_live_graph_is_canceled(struct lttng_live_msg_iter *msg_iter)
         return false;
     }
 
-    return bt_self_message_iterator_is_interrupted(msg_iter->self_msg_iter);
+    return bt_self_message_iterator_is_interrupted(msg_iter->selfMsgIter.libObjPtr());
 }
 
 static struct lttng_live_trace *
@@ -361,7 +361,7 @@ lttng_live_get_session(struct lttng_live_msg_iter *lttng_live_msg_iter,
      * Now that we have the metadata we can initialize the downstream
      * iterator.
      */
-    return lttng_live_lazy_msg_init(session, lttng_live_msg_iter->self_msg_iter);
+    return lttng_live_lazy_msg_init(session, lttng_live_msg_iter->selfMsgIter);
 }
 
 static void
@@ -472,7 +472,7 @@ emit_inactivity_message(struct lttng_live_msg_iter *lttng_live_msg_iter,
                     timestamp);
 
     const auto msg = bt_message_message_iterator_inactivity_create(
-        lttng_live_msg_iter->self_msg_iter, stream_iter->trace->clock_class->libObjPtr(),
+        lttng_live_msg_iter->selfMsgIter.libObjPtr(), stream_iter->trace->clock_class->libObjPtr(),
         timestamp);
 
     if (!msg) {
@@ -919,13 +919,13 @@ handle_late_message(struct lttng_live_msg_iter *lttng_live_msg_iter,
     const auto adjust_status = bt2c::call([&] {
         switch (late_msg.type()) {
         case bt2::MessageType::DiscardedEvents:
-            return adjust_discarded_events_message(lttng_live_msg_iter->self_msg_iter,
+            return adjust_discarded_events_message(lttng_live_msg_iter->selfMsgIter.libObjPtr(),
                                                    *stream_iter->stream,
                                                    late_msg.asDiscardedEvents(), adjustedMessage,
                                                    stream_iter->last_inactivity_ts.value);
 
         case bt2::MessageType::DiscardedPackets:
-            return adjust_discarded_packets_message(lttng_live_msg_iter->self_msg_iter,
+            return adjust_discarded_packets_message(lttng_live_msg_iter->selfMsgIter.libObjPtr(),
                                                     *stream_iter->stream,
                                                     late_msg.asDiscardedPackets(), adjustedMessage,
                                                     stream_iter->last_inactivity_ts.value);
@@ -1468,13 +1468,12 @@ return_status:
 
 static lttng_live_msg_iter::UP
 lttng_live_msg_iter_create(struct lttng_live_component *lttng_live_comp,
-                           bt_self_message_iterator *self_msg_it)
+                           const bt2::SelfMessageIterator selfMsgIter)
 {
-    auto msg_iter = bt2s::make_unique<struct lttng_live_msg_iter>(lttng_live_comp->logger,
-                                                                  lttng_live_comp->selfComp);
+    auto msg_iter = bt2s::make_unique<struct lttng_live_msg_iter>(
+        lttng_live_comp->logger, lttng_live_comp->selfComp, selfMsgIter);
 
     msg_iter->lttng_live_comp = lttng_live_comp;
-    msg_iter->self_msg_iter = self_msg_it;
     msg_iter->active_stream_iter = 0;
     msg_iter->last_msg_ts_ns = INT64_MIN;
     msg_iter->was_interrupted = false;
@@ -1497,7 +1496,7 @@ lttng_live_msg_iter_init(bt_self_message_iterator *self_msg_it,
         BT_ASSERT(!lttng_live->has_msg_iter);
         lttng_live->has_msg_iter = true;
 
-        auto lttng_live_msg_iter = lttng_live_msg_iter_create(lttng_live, self_msg_it);
+        auto lttng_live_msg_iter = lttng_live_msg_iter_create(lttng_live, bt2::wrap(self_msg_it));
         if (!lttng_live_msg_iter) {
             BT_CPPLOGE_APPEND_CAUSE_SPEC(lttng_live->logger,
                                          "Failed to create lttng_live_msg_iter");
@@ -1628,9 +1627,6 @@ static bt2::Value::Shared lttng_live_query_support_info(const bt2::ConstMapValue
     struct bt_common_lttng_live_url_parts parts = {};
     bt_common_lttng_live_url_parts_deleter partsDeleter {parts};
 
-    /* Used by the logging macros */
-    __attribute__((unused)) bt_self_component *self_comp = NULL;
-
     const auto typeValue = params["type"];
     if (!typeValue) {
         BT_CPPLOGE_APPEND_CAUSE_AND_THROW_SPEC(logger, bt2::Error,
@@ -1795,7 +1791,6 @@ lttng_live_component_init(bt_self_component_source *self_comp_src,
     try {
         lttng_live_component::UP lttng_live;
         bt_component_class_initialize_method_status ret;
-        bt_self_component *self_comp = bt_self_component_source_as_self_component(self_comp_src);
         bt_self_component_add_port_status add_port_status;
 
         ret = lttng_live_component_create(params, self_comp_src, lttng_live);
@@ -1810,7 +1805,8 @@ lttng_live_component_init(bt_self_component_source *self_comp_src,
             return ret;
         }
 
-        bt_self_component_set_data(self_comp, lttng_live.release());
+        bt_self_component_set_data(bt_self_component_source_as_self_component(self_comp_src),
+                                   lttng_live.release());
 
         return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK;
     } catch (const std::bad_alloc&) {
index 19df6353a446a803aa92b3823ef9522533aeae72..384cc424194944e219c6e87374dbe75df79d6260 100644 (file)
@@ -336,9 +336,10 @@ struct lttng_live_msg_iter
     using UP = std::unique_ptr<lttng_live_msg_iter>;
 
     explicit lttng_live_msg_iter(const bt2c::Logger& parentLogger,
-                                 const bt2::SelfComponent selfCompParam) :
+                                 const bt2::SelfComponent selfCompParam,
+                                 const bt2::SelfMessageIterator selfMsgIter) :
         logger {parentLogger, "PLUGIN/SRC.CTF.LTTNG-LIVE/MSG-ITER"},
-        selfComp {selfCompParam}
+        selfComp {selfCompParam}, selfMsgIter {selfMsgIter}
     {
     }
 
@@ -351,8 +352,7 @@ struct lttng_live_msg_iter
     /* Weak reference. */
     struct lttng_live_component *lttng_live_comp = nullptr;
 
-    /* Weak reference. */
-    bt_self_message_iterator *self_msg_iter = nullptr;
+    bt2::SelfMessageIterator selfMsgIter;
 
     live_viewer_connection::UP viewer_connection;
 
@@ -432,7 +432,7 @@ bt_component_class_query_method_status lttng_live_query(bt_self_component_class_
 void lttng_live_component_finalize(bt_self_component_source *component);
 
 bt_message_iterator_class_next_method_status
-lttng_live_msg_iter_next(bt_self_message_iterator *iterator, bt_message_array_const msgs,
+lttng_live_msg_iter_next(bt_self_message_iterator *self_msg_it, bt_message_array_const msgs,
                          uint64_t capacity, uint64_t *count);
 
 bt_message_iterator_class_initialize_method_status
This page took 0.033976 seconds and 4 git commands to generate.