From f0010051db62783ef057e8a6b625d6b4444671c2 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Wed, 1 Aug 2018 16:43:10 -0400 Subject: [PATCH] lib: use priv connection priv notif iterator to create notif, not graph The only valid location to create a notification object is within the "next" method of a user private connection notification iterator. To enforce this, make the notification creation functions accept a `bt_private_connection_private_notification_iterator` object instead of a `bt_graph` object to find the appropriate notification object pool (still located within the graph object). As of this patch, you cannot create a notification object outside the implementation of a user private connection notification iterator. This should also help the adaptation of the Python bindings to create a notification object using a method from `self` when implementing a user notification iterator: class MyIter(bt2._UserNotificationIterator): # ... def __next__(self): # ... event_notif = self._create_event_notification(...) # ... Signed-off-by: Philippe Proulx --- include/babeltrace/graph/notification-event.h | 4 ++- .../graph/notification-inactivity.h | 3 +- .../babeltrace/graph/notification-packet.h | 7 ++-- .../babeltrace/graph/notification-stream.h | 5 +-- lib/graph/notification/event.c | 10 ++++-- lib/graph/notification/inactivity.c | 3 +- lib/graph/notification/packet.c | 15 ++++++-- lib/graph/notification/stream.c | 7 ++-- plugins/ctf/common/notif-iter/notif-iter.c | 31 +++++++++-------- plugins/ctf/common/notif-iter/notif-iter.h | 2 +- plugins/ctf/fs-src/data-stream-file.c | 7 ++-- plugins/ctf/fs-src/data-stream-file.h | 4 +-- plugins/ctf/fs-src/fs.c | 7 ++-- plugins/ctf/fs-src/fs.h | 2 +- plugins/text/dmesg/dmesg.c | 34 +++++++++---------- tests/lib/test_bt_notification_iterator.c | 34 +++++++++++-------- tests/plugins/test-utils-muxer.c | 25 +++++++++----- 17 files changed, 120 insertions(+), 80 deletions(-) diff --git a/include/babeltrace/graph/notification-event.h b/include/babeltrace/graph/notification-event.h index 07559581..46a81cc2 100644 --- a/include/babeltrace/graph/notification-event.h +++ b/include/babeltrace/graph/notification-event.h @@ -35,11 +35,13 @@ extern "C" { #endif struct bt_notification; +struct bt_private_connection_private_notification_iterator; struct bt_event; struct bt_event_class; extern -struct bt_notification *bt_notification_event_create(struct bt_graph *graph, +struct bt_notification *bt_notification_event_create( + struct bt_private_connection_private_notification_iterator *notification_iterator, struct bt_event_class *event_class, struct bt_packet *packet); extern struct bt_event *bt_notification_event_borrow_event( diff --git a/include/babeltrace/graph/notification-inactivity.h b/include/babeltrace/graph/notification-inactivity.h index e2466187..a69d30cd 100644 --- a/include/babeltrace/graph/notification-inactivity.h +++ b/include/babeltrace/graph/notification-inactivity.h @@ -33,12 +33,13 @@ extern "C" { #endif struct bt_notification; +struct bt_private_connection_private_notification_iterator; struct bt_clock_value; struct bt_clock_class; extern struct bt_notification *bt_notification_inactivity_create( - struct bt_graph *graph); + struct bt_private_connection_private_notification_iterator *notification_iterator); extern int bt_notification_inactivity_set_clock_value( struct bt_notification *notif, diff --git a/include/babeltrace/graph/notification-packet.h b/include/babeltrace/graph/notification-packet.h index e3c9d55b..3d03e7fe 100644 --- a/include/babeltrace/graph/notification-packet.h +++ b/include/babeltrace/graph/notification-packet.h @@ -35,15 +35,18 @@ extern "C" { #endif struct bt_notification; +struct bt_private_connection_private_notification_iterator; struct bt_packet; extern struct bt_notification *bt_notification_packet_begin_create( - struct bt_graph *graph, struct bt_packet *packet); + struct bt_private_connection_private_notification_iterator *notification_iterator, + struct bt_packet *packet); extern struct bt_notification *bt_notification_packet_end_create( - struct bt_graph *graph, struct bt_packet *packet); + struct bt_private_connection_private_notification_iterator *notification_iterator, + struct bt_packet *packet); extern struct bt_packet *bt_notification_packet_begin_borrow_packet( diff --git a/include/babeltrace/graph/notification-stream.h b/include/babeltrace/graph/notification-stream.h index 963a95ce..e95c7e5b 100644 --- a/include/babeltrace/graph/notification-stream.h +++ b/include/babeltrace/graph/notification-stream.h @@ -40,18 +40,19 @@ extern "C" { #endif struct bt_notification; +struct bt_private_connection_private_notification_iterator; struct bt_clock_class; struct bt_clock_value; struct bt_stream; extern struct bt_notification *bt_notification_stream_begin_create( - struct bt_graph *graph, + struct bt_private_connection_private_notification_iterator *notification_iterator, struct bt_stream *stream); extern struct bt_notification *bt_notification_stream_end_create( - struct bt_graph *graph, + struct bt_private_connection_private_notification_iterator *notification_iterator, struct bt_stream *stream); extern struct bt_stream *bt_notification_stream_begin_borrow_stream( diff --git a/lib/graph/notification/event.c b/lib/graph/notification/event.c index a6c7b0ae..c31694a6 100644 --- a/lib/graph/notification/event.c +++ b/lib/graph/notification/event.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -53,7 +54,8 @@ static inline bool event_class_has_trace(struct bt_event_class *event_class) } BT_HIDDEN -struct bt_notification *bt_notification_event_new(struct bt_graph *graph) +struct bt_notification *bt_notification_event_new( + struct bt_graph *graph) { struct bt_notification_event *notification = NULL; @@ -75,13 +77,15 @@ end: } struct bt_notification *bt_notification_event_create( - struct bt_graph *graph, + struct bt_private_connection_private_notification_iterator *notif_iter, struct bt_event_class *event_class, struct bt_packet *packet) { struct bt_notification_event *notification = NULL; struct bt_event *event; + struct bt_graph *graph; + BT_ASSERT_PRE_NON_NULL(notif_iter, "Notification iterator"); BT_ASSERT_PRE_NON_NULL(event_class, "Event class"); BT_ASSERT_PRE_NON_NULL(packet, "Packet"); BT_LOGD("Creating event notification object: " @@ -114,6 +118,8 @@ struct bt_notification *bt_notification_event_create( * to notify the graph (pool owner) so that it removes the * notification from its notification array. */ + graph = bt_private_connection_private_notification_iterator_borrow_graph( + notif_iter); notification = (void *) bt_notification_create_from_pool( &graph->event_notif_pool, graph); if (unlikely(!notification)) { diff --git a/lib/graph/notification/inactivity.c b/lib/graph/notification/inactivity.c index fab8f256..6c7c6cf4 100644 --- a/lib/graph/notification/inactivity.c +++ b/lib/graph/notification/inactivity.c @@ -29,6 +29,7 @@ #include #include #include +#include #include static @@ -43,7 +44,7 @@ void bt_notification_inactivity_destroy(struct bt_object *obj) } struct bt_notification *bt_notification_inactivity_create( - struct bt_graph *graph) + struct bt_private_connection_private_notification_iterator *notif_iter) { struct bt_notification_inactivity *notification; struct bt_notification *ret_notif = NULL; diff --git a/lib/graph/notification/packet.c b/lib/graph/notification/packet.c index 316eb613..c5c6a6e5 100644 --- a/lib/graph/notification/packet.c +++ b/lib/graph/notification/packet.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -65,12 +66,15 @@ end: } struct bt_notification *bt_notification_packet_begin_create( - struct bt_graph *graph, struct bt_packet *packet) + struct bt_private_connection_private_notification_iterator *notif_iter, + struct bt_packet *packet) { struct bt_notification_packet_begin *notification; struct bt_stream *stream; struct bt_stream_class *stream_class; + struct bt_graph *graph; + BT_ASSERT_PRE_NON_NULL(notif_iter, "Notification iterator"); BT_ASSERT_PRE_NON_NULL(packet, "Packet"); stream = bt_packet_borrow_stream(packet); BT_ASSERT(stream); @@ -84,6 +88,8 @@ struct bt_notification *bt_notification_packet_begin_create( stream_class, bt_stream_class_get_name(stream_class), bt_stream_class_get_id(stream_class)); + graph = bt_private_connection_private_notification_iterator_borrow_graph( + notif_iter); notification = (void *) bt_notification_create_from_pool( &graph->packet_begin_notif_pool, graph); if (!notification) { @@ -180,12 +186,15 @@ end: } struct bt_notification *bt_notification_packet_end_create( - struct bt_graph *graph, struct bt_packet *packet) + struct bt_private_connection_private_notification_iterator *notif_iter, + struct bt_packet *packet) { struct bt_notification_packet_end *notification; struct bt_stream *stream; struct bt_stream_class *stream_class; + struct bt_graph *graph; + BT_ASSERT_PRE_NON_NULL(notif_iter, "Notification iterator"); BT_ASSERT_PRE_NON_NULL(packet, "Packet"); stream = bt_packet_borrow_stream(packet); BT_ASSERT(stream); @@ -199,6 +208,8 @@ struct bt_notification *bt_notification_packet_end_create( stream_class, bt_stream_class_get_name(stream_class), bt_stream_class_get_id(stream_class)); + graph = bt_private_connection_private_notification_iterator_borrow_graph( + notif_iter); notification = (void *) bt_notification_create_from_pool( &graph->packet_end_notif_pool, graph); if (!notification) { diff --git a/lib/graph/notification/stream.c b/lib/graph/notification/stream.c index f8276195..c9e69431 100644 --- a/lib/graph/notification/stream.c +++ b/lib/graph/notification/stream.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -50,7 +51,8 @@ void bt_notification_stream_end_destroy(struct bt_object *obj) } struct bt_notification *bt_notification_stream_end_create( - struct bt_graph *graph, struct bt_stream *stream) + struct bt_private_connection_private_notification_iterator *notif_iter, + struct bt_stream *stream) { struct bt_notification_stream_end *notification; struct bt_stream_class *stream_class; @@ -155,7 +157,8 @@ void bt_notification_stream_begin_destroy(struct bt_object *obj) } struct bt_notification *bt_notification_stream_begin_create( - struct bt_graph *graph, struct bt_stream *stream) + struct bt_private_connection_private_notification_iterator *notif_iter, + struct bt_stream *stream) { int ret; struct bt_notification_stream_begin *notification; diff --git a/plugins/ctf/common/notif-iter/notif-iter.c b/plugins/ctf/common/notif-iter/notif-iter.c index 8a5089f0..37317a01 100644 --- a/plugins/ctf/common/notif-iter/notif-iter.c +++ b/plugins/ctf/common/notif-iter/notif-iter.c @@ -141,8 +141,8 @@ struct bt_notif_iter { /* Visit stack */ struct stack *stack; - /* Current graph to create notifications (weak) */ - struct bt_graph *graph; + /* Current notification iterator to create notifications (weak) */ + struct bt_private_connection_private_notification_iterator *notif_iter; /* * Current dynamic scope field pointer. @@ -1655,8 +1655,8 @@ enum bt_notif_iter_status set_current_event_notification( notit, notit->meta.event_class, bt_event_class_get_name(notit->meta.event_class), notit->packet); - BT_ASSERT(notit->graph); - notif = bt_notification_event_create(notit->graph, + BT_ASSERT(notit->notif_iter); + notif = bt_notification_event_create(notit->notif_iter, notit->meta.event_class, notit->packet); if (!notif) { BT_LOGE("Cannot create event notification: " @@ -2833,8 +2833,9 @@ void notify_new_stream(struct bt_notif_iter *notit, } BT_ASSERT(notit->stream); - BT_ASSERT(notit->graph); - ret = bt_notification_stream_begin_create(notit->graph, notit->stream); + BT_ASSERT(notit->notif_iter); + ret = bt_notification_stream_begin_create(notit->notif_iter, + notit->stream); if (!ret) { BT_LOGE("Cannot create stream beginning notification: " "notit-addr=%p, stream-addr=%p", @@ -2858,8 +2859,9 @@ void notify_end_of_stream(struct bt_notif_iter *notit, return; } - BT_ASSERT(notit->graph); - ret = bt_notification_stream_end_create(notit->graph, notit->stream); + BT_ASSERT(notit->notif_iter); + ret = bt_notification_stream_end_create(notit->notif_iter, + notit->stream); if (!ret) { BT_LOGE("Cannot create stream beginning notification: " "notit-addr=%p, stream-addr=%p", @@ -2944,8 +2946,8 @@ void notify_new_packet(struct bt_notif_iter *notit, } } - BT_ASSERT(notit->graph); - notif = bt_notification_packet_begin_create(notit->graph, + BT_ASSERT(notit->notif_iter); + notif = bt_notification_packet_begin_create(notit->notif_iter, notit->packet); if (!notif) { BT_LOGE("Cannot create packet beginning notification: " @@ -2970,8 +2972,9 @@ void notify_end_of_packet(struct bt_notif_iter *notit, return; } - BT_ASSERT(notit->graph); - notif = bt_notification_packet_end_create(notit->graph, notit->packet); + BT_ASSERT(notit->notif_iter); + notif = bt_notification_packet_end_create(notit->notif_iter, + notit->packet); if (!notif) { BT_LOGE("Cannot create packet end notification: " "notit-addr=%p, packet-addr=%p", @@ -3154,7 +3157,7 @@ void bt_notif_iter_destroy(struct bt_notif_iter *notit) enum bt_notif_iter_status bt_notif_iter_get_next_notification( struct bt_notif_iter *notit, - struct bt_graph *graph, + struct bt_private_connection_private_notification_iterator *notif_iter, struct bt_notification **notification) { int ret; @@ -3168,7 +3171,7 @@ enum bt_notif_iter_status bt_notif_iter_get_next_notification( goto end; } - notit->graph = graph; + notit->notif_iter = notif_iter; BT_LOGV("Getting next notification: notit-addr=%p", notit); diff --git a/plugins/ctf/common/notif-iter/notif-iter.h b/plugins/ctf/common/notif-iter/notif-iter.h index 33bd6faf..fe6f7c54 100644 --- a/plugins/ctf/common/notif-iter/notif-iter.h +++ b/plugins/ctf/common/notif-iter/notif-iter.h @@ -311,7 +311,7 @@ void bt_notif_iter_destroy(struct bt_notif_iter *notif_iter); BT_HIDDEN enum bt_notif_iter_status bt_notif_iter_get_next_notification( struct bt_notif_iter *notit, - struct bt_graph *graph, + struct bt_private_connection_private_notification_iterator *notif_iter, struct bt_notification **notification); /** diff --git a/plugins/ctf/fs-src/data-stream-file.c b/plugins/ctf/fs-src/data-stream-file.c index d51bf109..2af4d177 100644 --- a/plugins/ctf/fs-src/data-stream-file.c +++ b/plugins/ctf/fs-src/data-stream-file.c @@ -737,7 +737,8 @@ error: BT_HIDDEN struct ctf_fs_ds_file *ctf_fs_ds_file_create( struct ctf_fs_trace *ctf_fs_trace, - struct bt_graph *graph, struct bt_notif_iter *notif_iter, + struct bt_private_connection_private_notification_iterator *pc_notif_iter, + struct bt_notif_iter *notif_iter, struct bt_stream *stream, const char *path) { int ret; @@ -748,7 +749,7 @@ struct ctf_fs_ds_file *ctf_fs_ds_file_create( goto error; } - ds_file->graph = graph; + ds_file->pc_notif_iter = pc_notif_iter; ds_file->file = ctf_fs_file_create(); if (!ds_file->file) { goto error; @@ -826,7 +827,7 @@ enum bt_notification_iterator_status ctf_fs_ds_file_next( enum bt_notification_iterator_status status; notif_iter_status = bt_notif_iter_get_next_notification( - ds_file->notif_iter, ds_file->graph, notif); + ds_file->notif_iter, ds_file->pc_notif_iter, notif); switch (notif_iter_status) { case BT_NOTIF_ITER_STATUS_EOF: diff --git a/plugins/ctf/fs-src/data-stream-file.h b/plugins/ctf/fs-src/data-stream-file.h index be035606..13c6e840 100644 --- a/plugins/ctf/fs-src/data-stream-file.h +++ b/plugins/ctf/fs-src/data-stream-file.h @@ -86,7 +86,7 @@ struct ctf_fs_ds_file_info { struct ctf_fs_ds_file { /* Weak */ - struct bt_graph *graph; + struct bt_private_connection_private_notification_iterator *pc_notif_iter; /* Owned by this */ struct ctf_fs_file *file; @@ -126,7 +126,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_graph *graph, + struct bt_private_connection_private_notification_iterator *pc_notif_iter, struct bt_notif_iter *notif_iter, struct bt_stream *stream, const char *path); diff --git a/plugins/ctf/fs-src/fs.c b/plugins/ctf/fs-src/fs.c index 4cd70a21..59a7bcab 100644 --- a/plugins/ctf/fs-src/fs.c +++ b/plugins/ctf/fs-src/fs.c @@ -59,7 +59,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->graph, + notif_iter_data->pc_notif_iter, notif_iter_data->notif_iter, notif_iter_data->ds_file_group->stream, ds_file_info->path->str); @@ -256,8 +256,7 @@ enum bt_notification_iterator_status ctf_fs_iterator_init( goto error; } - notif_iter_data->graph = bt_component_borrow_graph( - bt_component_borrow_from_private(port_data->ctf_fs->priv_comp)); + notif_iter_data->pc_notif_iter = it; notif_iter_data->notif_iter = bt_notif_iter_create( port_data->ds_file_group->ctf_fs_trace->metadata->trace, bt_common_get_page_size() * 8, @@ -708,7 +707,7 @@ int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, goto error; } - ds_file = ctf_fs_ds_file_create(ctf_fs_trace, graph, notif_iter, + ds_file = ctf_fs_ds_file_create(ctf_fs_trace, NULL, notif_iter, NULL, path); if (!ds_file) { goto error; diff --git a/plugins/ctf/fs-src/fs.h b/plugins/ctf/fs-src/fs.h index 534cb6b5..101d427e 100644 --- a/plugins/ctf/fs-src/fs.h +++ b/plugins/ctf/fs-src/fs.h @@ -127,7 +127,7 @@ struct ctf_fs_port_data { struct ctf_fs_notif_iter_data { /* Weak */ - struct bt_graph *graph; + struct bt_private_connection_private_notification_iterator *pc_notif_iter; /* Weak, belongs to ctf_fs_trace */ struct ctf_fs_ds_file_group *ds_file_group; diff --git a/plugins/text/dmesg/dmesg.c b/plugins/text/dmesg/dmesg.c index 3bf57ef6..8cb9539c 100644 --- a/plugins/text/dmesg/dmesg.c +++ b/plugins/text/dmesg/dmesg.c @@ -44,6 +44,7 @@ struct dmesg_component; struct dmesg_notif_iter { struct dmesg_component *dmesg_comp; + struct bt_private_connection_private_notification_iterator *pc_notif_iter; /* Weak */ char *linebuf; size_t linebuf_len; FILE *fp; @@ -66,7 +67,6 @@ struct dmesg_component { bt_bool no_timestamp; } params; - struct bt_graph *graph; /* Weak */ struct bt_trace *trace; struct bt_stream_class *stream_class; struct bt_event_class *event_class; @@ -534,9 +534,6 @@ enum bt_component_status dmesg_init(struct bt_private_component *priv_comp, goto error; } - dmesg_comp->graph = bt_component_borrow_graph( - bt_component_borrow_from_private(priv_comp)); - BT_ASSERT(dmesg_comp->graph); dmesg_comp->params.path = g_string_new(NULL); if (!dmesg_comp->params.path) { BT_LOGE_STR("Failed to allocate a GString."); @@ -588,7 +585,7 @@ void dmesg_finalize(struct bt_private_component *priv_comp) static struct bt_notification *create_init_event_notif_from_line( - struct dmesg_component *dmesg_comp, + struct dmesg_notif_iter *notif_iter, const char *line, const char **new_start) { struct bt_event *event; @@ -600,6 +597,7 @@ struct bt_notification *create_init_event_notif_from_line( struct bt_field *eh_field = NULL; struct bt_field *ts_field = NULL; int ret = 0; + struct dmesg_component *dmesg_comp = notif_iter->dmesg_comp; *new_start = line; @@ -663,7 +661,7 @@ skip_ts: goto error; } - notif = bt_notification_event_create(dmesg_comp->graph, + notif = bt_notification_event_create(notif_iter->pc_notif_iter, dmesg_comp->event_class, dmesg_comp->packet); if (!notif) { BT_LOGE_STR("Cannot create event notification."); @@ -700,8 +698,7 @@ end: } static -int fill_event_payload_from_line(struct dmesg_component *dmesg_comp, - const char *line, struct bt_event *event) +int fill_event_payload_from_line(const char *line, struct bt_event *event) { struct bt_field *ep_field = NULL; struct bt_field *str_field = NULL; @@ -746,14 +743,15 @@ end: static struct bt_notification *create_notif_from_line( - struct dmesg_component *dmesg_comp, const char *line) + struct dmesg_notif_iter *dmesg_notif_iter, const char *line) { struct bt_event *event = NULL; struct bt_notification *notif = NULL; const char *new_start; int ret; - notif = create_init_event_notif_from_line(dmesg_comp, line, &new_start); + notif = create_init_event_notif_from_line(dmesg_notif_iter, + line, &new_start); if (!notif) { BT_LOGE_STR("Cannot create and initialize event notification from line."); goto error; @@ -761,8 +759,7 @@ struct bt_notification *create_notif_from_line( event = bt_notification_event_borrow_event(notif); BT_ASSERT(event); - ret = fill_event_payload_from_line(dmesg_comp, new_start, - event); + ret = fill_event_payload_from_line(new_start, event); if (ret) { BT_LOGE("Cannot fill event payload field from line: " "ret=%d", ret); @@ -819,6 +816,7 @@ enum bt_notification_iterator_status dmesg_notif_iter_init( dmesg_comp = bt_private_component_get_user_data(priv_comp); BT_ASSERT(dmesg_comp); dmesg_notif_iter->dmesg_comp = dmesg_comp; + dmesg_notif_iter->pc_notif_iter = priv_notif_iter; if (dmesg_comp->params.read_from_stdin) { dmesg_notif_iter->fp = stdin; @@ -924,8 +922,8 @@ enum bt_notification_iterator_status dmesg_notif_iter_next_one( } } - dmesg_notif_iter->tmp_event_notif = create_notif_from_line(dmesg_comp, - dmesg_notif_iter->linebuf); + dmesg_notif_iter->tmp_event_notif = create_notif_from_line( + dmesg_notif_iter, dmesg_notif_iter->linebuf); if (!dmesg_notif_iter->tmp_event_notif) { BT_LOGE("Cannot create event notification from line: " "dmesg-comp-addr=%p, line=\"%s\"", dmesg_comp, @@ -940,13 +938,13 @@ handle_state: case STATE_EMIT_STREAM_BEGINNING: BT_ASSERT(dmesg_notif_iter->tmp_event_notif); *notif = bt_notification_stream_begin_create( - dmesg_comp->graph, dmesg_comp->stream); + dmesg_notif_iter->pc_notif_iter, dmesg_comp->stream); dmesg_notif_iter->state = STATE_EMIT_PACKET_BEGINNING; break; case STATE_EMIT_PACKET_BEGINNING: BT_ASSERT(dmesg_notif_iter->tmp_event_notif); *notif = bt_notification_packet_begin_create( - dmesg_comp->graph, dmesg_comp->packet); + dmesg_notif_iter->pc_notif_iter, dmesg_comp->packet); dmesg_notif_iter->state = STATE_EMIT_EVENT; break; case STATE_EMIT_EVENT: @@ -956,12 +954,12 @@ handle_state: break; case STATE_EMIT_PACKET_END: *notif = bt_notification_packet_end_create( - dmesg_comp->graph, dmesg_comp->packet); + dmesg_notif_iter->pc_notif_iter, dmesg_comp->packet); dmesg_notif_iter->state = STATE_EMIT_STREAM_END; break; case STATE_EMIT_STREAM_END: *notif = bt_notification_stream_end_create( - dmesg_comp->graph, dmesg_comp->stream); + dmesg_notif_iter->pc_notif_iter, dmesg_comp->stream); dmesg_notif_iter->state = STATE_DONE; break; default: diff --git a/tests/lib/test_bt_notification_iterator.c b/tests/lib/test_bt_notification_iterator.c index d4511408..e70e51ea 100644 --- a/tests/lib/test_bt_notification_iterator.c +++ b/tests/lib/test_bt_notification_iterator.c @@ -88,6 +88,7 @@ static bool debug = false; static enum test current_test; static GArray *test_events; static struct bt_graph *graph; +static struct bt_private_connection_private_notification_iterator *cur_notif_iter; static struct bt_stream_class *src_stream_class; static struct bt_event_class *src_event_class; static struct bt_stream *src_stream1; @@ -406,52 +407,54 @@ void src_iter_next_seq_one(struct src_iter_user_data *user_data, switch (user_data->seq[user_data->at]) { case SEQ_INACTIVITY: - *notif = bt_notification_inactivity_create(graph); + *notif = bt_notification_inactivity_create(cur_notif_iter); break; case SEQ_STREAM1_BEGIN: - *notif = bt_notification_stream_begin_create(graph, + *notif = bt_notification_stream_begin_create(cur_notif_iter, src_stream1); break; case SEQ_STREAM2_BEGIN: - *notif = bt_notification_stream_begin_create(graph, + *notif = bt_notification_stream_begin_create(cur_notif_iter, src_stream2); break; case SEQ_STREAM1_END: - *notif = bt_notification_stream_end_create(graph, src_stream1); + *notif = bt_notification_stream_end_create(cur_notif_iter, + src_stream1); break; case SEQ_STREAM2_END: - *notif = bt_notification_stream_end_create(graph, src_stream2); + *notif = bt_notification_stream_end_create(cur_notif_iter, + src_stream2); break; case SEQ_STREAM1_PACKET1_BEGIN: - *notif = bt_notification_packet_begin_create(graph, + *notif = bt_notification_packet_begin_create(cur_notif_iter, src_stream1_packet1); break; case SEQ_STREAM1_PACKET2_BEGIN: - *notif = bt_notification_packet_begin_create(graph, + *notif = bt_notification_packet_begin_create(cur_notif_iter, src_stream1_packet2); break; case SEQ_STREAM2_PACKET1_BEGIN: - *notif = bt_notification_packet_begin_create(graph, + *notif = bt_notification_packet_begin_create(cur_notif_iter, src_stream2_packet1); break; case SEQ_STREAM2_PACKET2_BEGIN: - *notif = bt_notification_packet_begin_create(graph, + *notif = bt_notification_packet_begin_create(cur_notif_iter, src_stream2_packet2); break; case SEQ_STREAM1_PACKET1_END: - *notif = bt_notification_packet_end_create(graph, + *notif = bt_notification_packet_end_create(cur_notif_iter, src_stream1_packet1); break; case SEQ_STREAM1_PACKET2_END: - *notif = bt_notification_packet_end_create(graph, + *notif = bt_notification_packet_end_create(cur_notif_iter, src_stream1_packet2); break; case SEQ_STREAM2_PACKET1_END: - *notif = bt_notification_packet_end_create(graph, + *notif = bt_notification_packet_end_create(cur_notif_iter, src_stream2_packet1); break; case SEQ_STREAM2_PACKET2_END: - *notif = bt_notification_packet_end_create(graph, + *notif = bt_notification_packet_end_create(cur_notif_iter, src_stream2_packet2); break; case SEQ_EVENT_STREAM1_PACKET1: @@ -471,8 +474,8 @@ void src_iter_next_seq_one(struct src_iter_user_data *user_data, } if (event_packet) { - *notif = bt_notification_event_create(graph, src_event_class, - event_packet); + *notif = bt_notification_event_create(cur_notif_iter, + src_event_class, event_packet); } BT_ASSERT(*notif); @@ -518,6 +521,7 @@ enum bt_notification_iterator_status src_iter_next( bt_private_connection_private_notification_iterator_get_user_data(priv_iterator); BT_ASSERT(user_data); + cur_notif_iter = priv_iterator; return src_iter_next_seq(user_data, notifs, capacity, count); } diff --git a/tests/plugins/test-utils-muxer.c b/tests/plugins/test-utils-muxer.c index 17052313..73f51e76 100644 --- a/tests/plugins/test-utils-muxer.c +++ b/tests/plugins/test-utils-muxer.c @@ -73,6 +73,7 @@ static bool debug = false; static enum test current_test; static GArray *test_events; static struct bt_graph *graph; +static struct bt_private_connection_private_notification_iterator *cur_notif_iter; static struct bt_clock_class *src_clock_class; static struct bt_stream_class *src_stream_class; static struct bt_event_class *src_event_class; @@ -503,7 +504,8 @@ struct bt_notification *src_create_event_notif(struct bt_packet *packet, struct bt_notification *notif; struct bt_field *field; - notif = bt_notification_event_create(graph, src_event_class, packet); + notif = bt_notification_event_create(cur_notif_iter, + src_event_class, packet); BT_ASSERT(notif); event = bt_notification_event_borrow_event(notif); BT_ASSERT(event); @@ -544,24 +546,26 @@ enum bt_notification_iterator_status src_iter_next_seq( status = BT_NOTIFICATION_ITERATOR_STATUS_AGAIN; break; case SEQ_PACKET_BEGIN: - notifs[0] = bt_notification_packet_begin_create(graph, + notifs[0] = bt_notification_packet_begin_create(cur_notif_iter, user_data->packet); BT_ASSERT(notifs[0]); break; case SEQ_PACKET_END: - notifs[0] = bt_notification_packet_end_create(graph, + notifs[0] = bt_notification_packet_end_create(cur_notif_iter, user_data->packet); BT_ASSERT(notifs[0]); break; case SEQ_STREAM_BEGIN: stream = bt_packet_get_stream(user_data->packet); - notifs[0] = bt_notification_stream_begin_create(graph, stream); + notifs[0] = bt_notification_stream_begin_create(cur_notif_iter, + stream); BT_ASSERT(notifs[0]); bt_put(stream); break; case SEQ_STREAM_END: stream = bt_packet_get_stream(user_data->packet); - notifs[0] = bt_notification_stream_end_create(graph, stream); + notifs[0] = bt_notification_stream_end_create(cur_notif_iter, + stream); BT_ASSERT(notifs[0]); bt_put(stream); break; @@ -598,6 +602,7 @@ enum bt_notification_iterator_status src_iter_next( BT_ASSERT(user_data); BT_ASSERT(private_component); + cur_notif_iter = priv_iterator; /* * We can always set it to 1: it's not going to be considered @@ -613,13 +618,14 @@ enum bt_notification_iterator_status src_iter_next( stream = bt_packet_get_stream(user_data->packet); notifs[0] = bt_notification_stream_begin_create( - graph, stream); + cur_notif_iter, stream); bt_put(stream); BT_ASSERT(notifs[0]); } else if (user_data->at == 1) { notifs[0] = bt_notification_packet_begin_create( - graph, user_data->packet); + cur_notif_iter, + user_data->packet); BT_ASSERT(notifs[0]); } else if (user_data->at < 7) { notifs[0] = @@ -629,13 +635,14 @@ enum bt_notification_iterator_status src_iter_next( } else if (user_data->at == 7) { notifs[0] = bt_notification_packet_end_create( - graph, user_data->packet); + cur_notif_iter, + user_data->packet); BT_ASSERT(notifs[0]); } else if (user_data->at == 8) { stream = bt_packet_get_stream(user_data->packet); notifs[0] = bt_notification_stream_end_create( - graph, stream); + cur_notif_iter, stream); bt_put(stream); BT_ASSERT(notifs[0]); } else { -- 2.34.1