src.ctf.fs: make ctf_fs_ds_group_medops_data::file a ctf_fs_ds_file::UP
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 5 Dec 2023 04:03:12 +0000 (04:03 +0000)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Apr 2024 17:57:53 +0000 (13:57 -0400)
Change-Id: Ibe6b3882c29725f7563fb141bd823ec2adeabc6a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8271
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12309
Tested-by: jenkins <jenkins@lttng.org>
src/plugins/ctf/fs-src/data-stream-file.cpp

index c3114a69cd1ef21e13e9ffc919acbf447a503e18..c456104c746a7389e04d98effe218433970fa928 100644 (file)
@@ -280,10 +280,8 @@ struct ctf_fs_ds_group_medops_data
     /*
      * File we are currently reading.  Changes whenever we switch to
      * reading another data file.
-     *
-     * Owned by this.
      */
-    struct ctf_fs_ds_file *file = nullptr;
+    ctf_fs_ds_file::UP file;
 
     /* Weak, for context / logging / appending causes. */
     bt_self_message_iterator *self_msg_iter = nullptr;
@@ -296,7 +294,7 @@ static enum ctf_msg_iter_medium_status medop_group_request_bytes(size_t request_
     struct ctf_fs_ds_group_medops_data *data = (struct ctf_fs_ds_group_medops_data *) void_data;
 
     /* Return bytes from the current file. */
-    return medop_request_bytes(request_sz, buffer_addr, buffer_sz, data->file);
+    return medop_request_bytes(request_sz, buffer_addr, buffer_sz, data->file.get());
 }
 
 static bt_stream *medop_group_borrow_stream(bt_stream_class *stream_class, int64_t stream_id,
@@ -304,7 +302,7 @@ static bt_stream *medop_group_borrow_stream(bt_stream_class *stream_class, int64
 {
     struct ctf_fs_ds_group_medops_data *data = (struct ctf_fs_ds_group_medops_data *) void_data;
 
-    return medop_borrow_stream(stream_class, stream_id, data->file);
+    return medop_borrow_stream(stream_class, stream_id, data->file.get());
 }
 
 /*
@@ -323,14 +321,10 @@ ctf_fs_ds_group_medops_set_file(struct ctf_fs_ds_group_medops_data *data,
 
     /* Check if that file is already the one mapped. */
     if (!data->file || data->file->file->path != index_entry->path) {
-        /* Destroy the previously used file. */
-        delete 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,
-                                  index_entry->path, data->logger)
-                .release();
+                                  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;
@@ -342,7 +336,7 @@ ctf_fs_ds_group_medops_set_file(struct ctf_fs_ds_group_medops_data *data,
      * Ensure the right portion of the file will be returned on the next
      * request_bytes call.
      */
-    status = ds_file_mmap(data->file, index_entry->offset.bytes());
+    status = ds_file_mmap(data->file.get(), index_entry->offset.bytes());
     if (status != CTF_MSG_ITER_MEDIUM_STATUS_OK) {
         goto end;
     }
@@ -389,8 +383,6 @@ void ctf_fs_ds_group_medops_data_destroy(struct ctf_fs_ds_group_medops_data *dat
         goto end;
     }
 
-    delete data->file;
-
     delete data;
 
 end:
This page took 0.025466 seconds and 4 git commands to generate.