src.ctf.lttng-live: make lttng_live_stream_iterator::stream a bt2::Stream::Shared
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 7 Dec 2023 04:26:25 +0000 (04:26 +0000)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Apr 2024 17:57:53 +0000 (13:57 -0400)
Change-Id: Ia38f2feba1040749df692574e67861c81a73e8df
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8454
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12369
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

index cf49b7e39a84839646ebadcde026d2bd2e585d68..8a68650bdb5e341f4cec4a090e4caa25299194bf 100644 (file)
@@ -71,6 +71,8 @@ static bt_stream *medop_borrow_stream(bt_stream_class *stream_class, int64_t str
                         "Creating stream {} (ID: {}) out of stream class {}",
                         lttng_live_stream->name->str, stream_id, stream_class_id);
 
+        bt_stream *stream;
+
         if (stream_id < 0) {
             /*
              * No stream instance ID in the stream. It's possible
@@ -78,27 +80,27 @@ 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 =
+            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 = bt_stream_create_with_id(
                 stream_class, lttng_live_stream->trace->trace->libObjPtr(), (uint64_t) stream_id);
         }
 
-        if (!lttng_live_stream->stream) {
+        if (!stream) {
             BT_CPPLOGE_APPEND_CAUSE_SPEC(
                 lttng_live_stream->logger,
                 "Cannot create stream {} (stream class ID {}, stream ID {})",
                 lttng_live_stream->name->str, stream_class_id, stream_id);
-            goto end;
+            return nullptr;
         }
 
-        bt_stream_set_name(lttng_live_stream->stream, lttng_live_stream->name->str);
+        lttng_live_stream->stream = bt2::Stream::Shared::createWithoutRef(stream);
+        lttng_live_stream->stream->name(lttng_live_stream->name->str);
     }
 
-end:
-    return lttng_live_stream->stream;
+    return lttng_live_stream->stream->libObjPtr();
 }
 
 static struct ctf_msg_iter_medium_ops medops = {
@@ -241,10 +243,6 @@ void lttng_live_stream_iterator_destroy(struct lttng_live_stream_iterator *strea
         return;
     }
 
-    if (stream_iter->stream) {
-        BT_STREAM_PUT_REF_AND_RESET(stream_iter->stream);
-    }
-
     if (stream_iter->msg_iter) {
         ctf_msg_iter_destroy(stream_iter->msg_iter);
     }
index 4d4dd162de0e62738d2ac2425b93cc61349fafae..ae7e45b1798c4b9cb288b38f9888fb011986a76f 100644 (file)
@@ -1069,7 +1069,7 @@ handle_late_message(struct lttng_live_msg_iter *lttng_live_msg_iter,
         goto end;
     }
 
-    stream_class = bt_stream_borrow_class_const(stream_iter->stream);
+    stream_class = bt_stream_borrow_class_const(stream_iter->stream->libObjPtr());
     clock_class = bt_stream_class_borrow_default_clock_class_const(stream_class);
 
     ts_ns_status = bt_clock_class_cycles_to_ns_from_origin(
@@ -1105,13 +1105,13 @@ handle_late_message(struct lttng_live_msg_iter *lttng_live_msg_iter,
     switch (bt_message_get_type(late_msg)) {
     case BT_MESSAGE_TYPE_DISCARDED_EVENTS:
         adjust_status = adjust_discarded_events_message(
-            lttng_live_msg_iter->self_msg_iter, stream_iter->stream, late_msg, &adjusted_message,
-            stream_iter->last_inactivity_ts.value);
+            lttng_live_msg_iter->self_msg_iter, stream_iter->stream->libObjPtr(), late_msg,
+            &adjusted_message, stream_iter->last_inactivity_ts.value);
         break;
     case BT_MESSAGE_TYPE_DISCARDED_PACKETS:
         adjust_status = adjust_discarded_packets_message(
-            lttng_live_msg_iter->self_msg_iter, stream_iter->stream, late_msg, &adjusted_message,
-            stream_iter->last_inactivity_ts.value);
+            lttng_live_msg_iter->self_msg_iter, stream_iter->stream->libObjPtr(), late_msg,
+            &adjusted_message, stream_iter->last_inactivity_ts.value);
         break;
     default:
         bt_common_abort();
index a8ec55fc14055625750a9130d1ff43f527dd60ad..2ed6448102d01f172470f15c90b86d509f3c3722 100644 (file)
@@ -74,8 +74,7 @@ struct lttng_live_stream_iterator
 
     bt2c::Logger logger;
 
-    /* Owned by this. */
-    bt_stream *stream = nullptr;
+    bt2::Stream::Shared stream;
 
     /* Weak reference. */
     struct lttng_live_trace *trace = nullptr;
This page took 0.030358 seconds and 4 git commands to generate.