src.ctf.fs: use one CTF notif iter per notification iterator
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 20 Jun 2017 18:36:52 +0000 (14:36 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 6 Jul 2017 20:13:13 +0000 (16:13 -0400)
Use only one bt_ctf_notif_iter per src.ctf.fs notification iterator,
instead of one per data stream file, so that this object can keep a
state for the whole packet sequence.

ctf_fs_ds_file_create() now receives the notif iter to use and sets
itself as its current medops user data.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
plugins/ctf/common/notif-iter/notif-iter.c
plugins/ctf/common/notif-iter/notif-iter.h
plugins/ctf/fs-src/data-stream-file.c
plugins/ctf/fs-src/data-stream-file.h
plugins/ctf/fs-src/fs.c
plugins/ctf/fs-src/fs.h

index 06818d0e10a89f660953ee3c7ec948e73ead8b27..06125b2315e3579bca9455c4b41b3c3ea0af9330 100644 (file)
@@ -3129,3 +3129,11 @@ set_fields:
 end:
        return status;
 }
+
+BT_HIDDEN
+void bt_ctf_notif_iter_set_medops_data(struct bt_ctf_notif_iter *notit,
+               void *medops_data)
+{
+       assert(notit);
+       notit->medium.data = medops_data;
+}
index 988e54baf50e025e7f6a1054371632628353ca64..428dd2eca2332644fdd5c7224d60b58db711761a 100644 (file)
@@ -302,6 +302,10 @@ enum bt_ctf_notif_iter_status bt_ctf_notif_iter_get_packet_header_context_fields
                struct bt_ctf_field **packet_header_field,
                struct bt_ctf_field **packet_context_field);
 
+BT_HIDDEN
+void bt_ctf_notif_iter_set_medops_data(struct bt_ctf_notif_iter *notit,
+               void *medops_data);
+
 static inline
 const char *bt_ctf_notif_iter_medium_status_string(
                enum bt_ctf_notif_iter_medium_status status)
index 5d255ab78441ecf08bc882fc9ac4dbb3547c3672..0ca01a61606f67c5d831c7568bc42bc2dbf58916 100644 (file)
@@ -199,10 +199,12 @@ end:
        return stream;
 }
 
-static struct bt_ctf_notif_iter_medium_ops medops = {
+BT_HIDDEN
+struct bt_ctf_notif_iter_medium_ops ctf_fs_ds_file_medops = {
        .request_bytes = medop_request_bytes,
        .get_stream = medop_get_stream,
 };
+
 static
 struct ctf_fs_ds_index *ctf_fs_ds_index_create(size_t length)
 {
@@ -521,6 +523,7 @@ error:
 BT_HIDDEN
 struct ctf_fs_ds_file *ctf_fs_ds_file_create(
                struct ctf_fs_trace *ctf_fs_trace,
+               struct bt_ctf_notif_iter *notif_iter,
                struct bt_ctf_stream *stream, const char *path)
 {
        int ret;
@@ -544,8 +547,8 @@ struct ctf_fs_ds_file *ctf_fs_ds_file_create(
                goto error;
        }
 
-       ds_file->notif_iter = bt_ctf_notif_iter_create(
-               ctf_fs_trace->metadata->trace, page_size, medops, ds_file);
+       ds_file->notif_iter = notif_iter;
+       bt_ctf_notif_iter_set_medops_data(ds_file->notif_iter, ds_file);
        if (!ds_file->notif_iter) {
                goto error;
        }
@@ -585,10 +588,6 @@ void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *ds_file)
                ctf_fs_file_destroy(ds_file->file);
        }
 
-       if (ds_file->notif_iter) {
-               bt_ctf_notif_iter_destroy(ds_file->notif_iter);
-       }
-
        g_free(ds_file);
 }
 
index 99efd36fae3df5a75db12f0bcb022ac1c41f36ba..8b2d7247fb91797ee3b759a567916cbb698c4cc7 100644 (file)
@@ -94,7 +94,7 @@ struct ctf_fs_ds_file {
        /* Owned by this */
        struct bt_clock_class_priority_map *cc_prio_map;
 
-       /* Owned by this */
+       /* Weak */
        struct bt_ctf_notif_iter *notif_iter;
 
        void *mmap_addr;
@@ -123,6 +123,7 @@ struct ctf_fs_ds_file {
 BT_HIDDEN
 struct ctf_fs_ds_file *ctf_fs_ds_file_create(
                struct ctf_fs_trace *ctf_fs_trace,
+               struct bt_ctf_notif_iter *notif_iter,
                struct bt_ctf_stream *stream, const char *path);
 
 BT_HIDDEN
@@ -145,4 +146,6 @@ struct ctf_fs_ds_index *ctf_fs_ds_file_build_index(
 BT_HIDDEN
 void ctf_fs_ds_index_destroy(struct ctf_fs_ds_index *index);
 
+extern struct bt_ctf_notif_iter_medium_ops ctf_fs_ds_file_medops;
+
 #endif /* CTF_FS_DS_FILE_H */
index 07aa8cf36f9d724b0ab02dcc3b903533c501b4f4..7d004fe4106620ebaf3a46b310c0e63c05d4ea9b 100644 (file)
@@ -47,6 +47,7 @@
 #include "data-stream-file.h"
 #include "file.h"
 #include "../common/metadata/decoder.h"
+#include "../common/notif-iter/notif-iter.h"
 #include "query.h"
 
 #define BT_LOG_TAG "PLUGIN-CTF-FS-SRC"
@@ -67,6 +68,7 @@ int notif_iter_data_set_current_ds_file(struct ctf_fs_notif_iter_data *notif_ite
        ctf_fs_ds_file_destroy(notif_iter_data->ds_file);
        notif_iter_data->ds_file = ctf_fs_ds_file_create(
                notif_iter_data->ds_file_group->ctf_fs_trace,
+               notif_iter_data->notif_iter,
                notif_iter_data->ds_file_group->stream,
                ds_file_info->path->str);
        if (!notif_iter_data->ds_file) {
@@ -85,6 +87,11 @@ void ctf_fs_notif_iter_data_destroy(
        }
 
        ctf_fs_ds_file_destroy(notif_iter_data->ds_file);
+
+       if (notif_iter_data->notif_iter) {
+               bt_ctf_notif_iter_destroy(notif_iter_data->notif_iter);
+       }
+
        g_free(notif_iter_data);
 }
 
@@ -168,6 +175,16 @@ enum bt_notification_iterator_status ctf_fs_iterator_init(
                goto error;
        }
 
+       notif_iter_data->notif_iter = bt_ctf_notif_iter_create(
+               port_data->ds_file_group->ctf_fs_trace->metadata->trace,
+               bt_common_get_page_size() * 8,
+               ctf_fs_ds_file_medops, NULL);
+       if (!notif_iter_data->notif_iter) {
+               BT_LOGE_STR("Cannot create a CTF notification iterator.");
+               ret = BT_NOTIFICATION_ITERATOR_STATUS_NOMEM;
+               goto error;
+       }
+
        notif_iter_data->ds_file_group = port_data->ds_file_group;
        iret = notif_iter_data_set_current_ds_file(notif_iter_data);
        if (iret) {
@@ -636,10 +653,18 @@ int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace,
        bool add_group = false;
        int ret;
        size_t i;
-       struct ctf_fs_ds_file *ds_file;
+       struct ctf_fs_ds_file *ds_file = NULL;
        struct ctf_fs_ds_index *index = NULL;
+       struct bt_ctf_notif_iter *notif_iter = NULL;
 
-       ds_file = ctf_fs_ds_file_create(ctf_fs_trace, NULL, path);
+       notif_iter = bt_ctf_notif_iter_create(ctf_fs_trace->metadata->trace,
+               bt_common_get_page_size() * 8, ctf_fs_ds_file_medops, NULL);
+       if (!notif_iter) {
+               BT_LOGE_STR("Cannot create a CTF notification iterator.");
+               goto error;
+       }
+
+       ds_file = ctf_fs_ds_file_create(ctf_fs_trace, notif_iter, NULL, path);
        if (!ds_file) {
                goto error;
        }
@@ -757,6 +782,11 @@ end:
                g_ptr_array_add(ctf_fs_trace->ds_file_groups, ds_file_group);
        }
        ctf_fs_ds_file_destroy(ds_file);
+
+       if (notif_iter) {
+               bt_ctf_notif_iter_destroy(notif_iter);
+       }
+
        ctf_fs_ds_index_destroy(index);
        bt_put(packet_header_field);
        bt_put(packet_context_field);
index 13b0d07c6b5e802e64d50f38bef5523894ca7d37..64eab95b921bb9c45871edf8b496a69d7d1d14c2 100644 (file)
@@ -123,6 +123,9 @@ struct ctf_fs_notif_iter_data {
 
        /* Which file the iterator is _currently_ operating on */
        size_t ds_file_info_index;
+
+       /* Owned by this */
+       struct bt_ctf_notif_iter *notif_iter;
 };
 
 BT_HIDDEN
This page took 0.028802 seconds and 4 git commands to generate.