src.ctf.fs: make ctf_fs_ds_file::stream a bt2::Stream::Shared
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 4 Dec 2023 21:51:03 +0000 (21:51 +0000)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Apr 2024 17:57:53 +0000 (13:57 -0400)
Change-Id: I2df309d73c7a1b987e4d25c63251e13bf47a38a3
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8258
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12296

src/plugins/ctf/fs-src/data-stream-file.cpp
src/plugins/ctf/fs-src/data-stream-file.hpp
src/plugins/ctf/fs-src/fs.cpp

index 97e688e4dbc670f429baab368e9aaedfc6ec5123..bde54c7e1dc3111da6cbff458f23d80927105686 100644 (file)
@@ -225,7 +225,7 @@ static bt_stream *medop_borrow_stream(bt_stream_class *stream_class, int64_t, vo
     bt_stream_class *ds_file_stream_class;
     bt_stream *stream = NULL;
 
-    ds_file_stream_class = bt_stream_borrow_class(ds_file->stream);
+    ds_file_stream_class = ds_file->stream->cls().libObjPtr();
 
     if (stream_class != ds_file_stream_class) {
         /*
@@ -235,7 +235,7 @@ static bt_stream *medop_borrow_stream(bt_stream_class *stream_class, int64_t, vo
         goto end;
     }
 
-    stream = ds_file->stream;
+    stream = ds_file->stream->libObjPtr();
 
 end:
     return stream;
@@ -327,9 +327,9 @@ ctf_fs_ds_group_medops_set_file(struct ctf_fs_ds_group_medops_data *data,
         ctf_fs_ds_file_destroy(data->file);
 
         /* Create the new file. */
-        data->file = ctf_fs_ds_file_create(data->ds_file_group->ctf_fs_trace,
-                                           data->ds_file_group->stream->libObjPtr(),
-                                           index_entry->path, data->logger);
+        data->file =
+            ctf_fs_ds_file_create(data->ds_file_group->ctf_fs_trace, data->ds_file_group->stream,
+                                  index_entry->path, data->logger);
         if (!data->file) {
             BT_CPPLOGE_APPEND_CAUSE_SPEC(data->logger, "failed to create ctf_fs_ds_file.");
             status = CTF_MSG_ITER_MEDIUM_STATUS_ERROR;
@@ -811,8 +811,9 @@ error:
     goto end;
 }
 
-struct ctf_fs_ds_file *ctf_fs_ds_file_create(struct ctf_fs_trace *ctf_fs_trace, bt_stream *stream,
-                                             const char *path, const bt2c::Logger& parentLogger)
+struct ctf_fs_ds_file *ctf_fs_ds_file_create(struct ctf_fs_trace *ctf_fs_trace,
+                                             bt2::Stream::Shared stream, const char *path,
+                                             const bt2c::Logger& parentLogger)
 {
     int ret;
     size_t offset_align;
@@ -827,8 +828,7 @@ struct ctf_fs_ds_file *ctf_fs_ds_file_create(struct ctf_fs_trace *ctf_fs_trace,
         goto error;
     }
 
-    ds_file->stream = stream;
-    bt_stream_get_ref(ds_file->stream);
+    ds_file->stream = std::move(stream);
     ds_file->metadata = ctf_fs_trace->metadata;
     g_string_assign(ds_file->file->path, path);
     ret = ctf_fs_file_open(ds_file->file, "rb");
@@ -877,7 +877,6 @@ void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *ds_file)
         return;
     }
 
-    bt_stream_put_ref(ds_file->stream);
     (void) ds_file_munmap(ds_file);
 
     if (ds_file->file) {
index fed80c61585f73c18d801fa8ff2222416692151b..bdbf477d88c278d3ac25e5fc354cc8607d798612 100644 (file)
@@ -47,8 +47,7 @@ struct ctf_fs_ds_file
     /* Owned by this */
     struct ctf_fs_file *file = nullptr;
 
-    /* Owned by this */
-    bt_stream *stream = nullptr;
+    bt2::Stream::Shared stream;
 
     void *mmap_addr = nullptr;
 
@@ -143,7 +142,7 @@ struct ctf_fs_ds_file_group
     ctf_fs_ds_index::UP index;
 };
 
-struct ctf_fs_ds_file *ctf_fs_ds_file_create(struct ctf_fs_trace *ctf_fs_trace, bt_stream *stream,
+struct ctf_fs_ds_file *ctf_fs_ds_file_create(ctf_fs_trace *ctf_fs_trace, bt2::Stream::Shared stream,
                                              const char *path, const bt2c::Logger& logger);
 
 void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *stream);
index 1db4fe658d03ba29332fcfef19cf5774ae32d390..ac4c720c816ef37f7bed3ee552f6b746572df7b8 100644 (file)
@@ -523,7 +523,8 @@ static int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, const
      * Create a temporary ds_file to read some properties about the data
      * stream file.
      */
-    ds_file = ctf_fs_ds_file_create(ctf_fs_trace, NULL, path, ctf_fs_trace->logger);
+    ds_file =
+        ctf_fs_ds_file_create(ctf_fs_trace, bt2::Stream::Shared {}, path, ctf_fs_trace->logger);
     if (!ds_file) {
         goto error;
     }
@@ -1135,7 +1136,8 @@ static int decode_clock_snapshot_after_event(struct ctf_fs_trace *ctf_fs_trace,
     BT_ASSERT(index_entry);
     BT_ASSERT(index_entry->path);
 
-    ds_file = ctf_fs_ds_file_create(ctf_fs_trace, NULL, index_entry->path, ctf_fs_trace->logger);
+    ds_file = ctf_fs_ds_file_create(ctf_fs_trace, bt2::Stream::Shared {}, index_entry->path,
+                                    ctf_fs_trace->logger);
     if (!ds_file) {
         BT_CPPLOGE_APPEND_CAUSE_SPEC(ctf_fs_trace->logger, "Failed to create a ctf_fs_ds_file");
         ret = -1;
This page took 0.026439 seconds and 4 git commands to generate.