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>
+
+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;
+}
struct bt_ctf_field **packet_header_field,
struct bt_ctf_field **packet_context_field);
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)
static inline
const char *bt_ctf_notif_iter_medium_status_string(
enum bt_ctf_notif_iter_medium_status status)
-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,
};
.request_bytes = medop_request_bytes,
.get_stream = medop_get_stream,
};
static
struct ctf_fs_ds_index *ctf_fs_ds_index_create(size_t length)
{
static
struct ctf_fs_ds_index *ctf_fs_ds_index_create(size_t length)
{
BT_HIDDEN
struct ctf_fs_ds_file *ctf_fs_ds_file_create(
struct ctf_fs_trace *ctf_fs_trace,
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;
struct bt_ctf_stream *stream, const char *path)
{
int ret;
- 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;
}
if (!ds_file->notif_iter) {
goto error;
}
ctf_fs_file_destroy(ds_file->file);
}
ctf_fs_file_destroy(ds_file->file);
}
- if (ds_file->notif_iter) {
- bt_ctf_notif_iter_destroy(ds_file->notif_iter);
- }
-
/* Owned by this */
struct bt_clock_class_priority_map *cc_prio_map;
/* Owned by this */
struct bt_clock_class_priority_map *cc_prio_map;
struct bt_ctf_notif_iter *notif_iter;
void *mmap_addr;
struct bt_ctf_notif_iter *notif_iter;
void *mmap_addr;
BT_HIDDEN
struct ctf_fs_ds_file *ctf_fs_ds_file_create(
struct ctf_fs_trace *ctf_fs_trace,
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
struct bt_ctf_stream *stream, const char *path);
BT_HIDDEN
BT_HIDDEN
void ctf_fs_ds_index_destroy(struct ctf_fs_ds_index *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 */
#endif /* CTF_FS_DS_FILE_H */
#include "data-stream-file.h"
#include "file.h"
#include "../common/metadata/decoder.h"
#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"
#include "query.h"
#define BT_LOG_TAG "PLUGIN-CTF-FS-SRC"
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,
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) {
notif_iter_data->ds_file_group->stream,
ds_file_info->path->str);
if (!notif_iter_data->ds_file) {
}
ctf_fs_ds_file_destroy(notif_iter_data->ds_file);
}
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);
}
g_free(notif_iter_data);
}
+ 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) {
notif_iter_data->ds_file_group = port_data->ds_file_group;
iret = notif_iter_data_set_current_ds_file(notif_iter_data);
if (iret) {
bool add_group = false;
int ret;
size_t i;
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 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;
}
if (!ds_file) {
goto error;
}
g_ptr_array_add(ctf_fs_trace->ds_file_groups, ds_file_group);
}
ctf_fs_ds_file_destroy(ds_file);
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);
ctf_fs_ds_index_destroy(index);
bt_put(packet_header_field);
bt_put(packet_context_field);
/* Which file the iterator is _currently_ operating on */
size_t ds_file_info_index;
/* Which file the iterator is _currently_ operating on */
size_t ds_file_info_index;
+
+ /* Owned by this */
+ struct bt_ctf_notif_iter *notif_iter;