lib: use priv connection priv notif iterator to create notif, not graph
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 1 Aug 2018 20:43:10 +0000 (16:43 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 2 May 2019 04:07:36 +0000 (00:07 -0400)
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 <eeppeliteloop@gmail.com>
17 files changed:
include/babeltrace/graph/notification-event.h
include/babeltrace/graph/notification-inactivity.h
include/babeltrace/graph/notification-packet.h
include/babeltrace/graph/notification-stream.h
lib/graph/notification/event.c
lib/graph/notification/inactivity.c
lib/graph/notification/packet.c
lib/graph/notification/stream.c
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
plugins/text/dmesg/dmesg.c
tests/lib/test_bt_notification_iterator.c
tests/plugins/test-utils-muxer.c

index 07559581373d542dbfcc99f5d2a23777914f88e7..46a81cc202e4db5d503013800f152355774e8987 100644 (file)
@@ -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(
index e246618799c971a638eeac5c532fda86fa707ec1..a69d30cd25a28aba300f9a9042cd7bcfb284704b 100644 (file)
@@ -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,
index e3c9d55b401e094c5d575497b69a157c050d932c..3d03e7fe25970847206b8e3b18a0041fde488163 100644 (file)
@@ -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(
index 963a95ce4c9fc0b7b87425b8934b8b7b337fea87..e95c7e5b2007b18dee515014788da6ab92735e28 100644 (file)
@@ -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(
index a6c7b0ae2fa3e2fd8ec5da5a16f5e6ce6d484761..c31694a625adbc533f14d16096509e4435195a8b 100644 (file)
@@ -36,6 +36,7 @@
 #include <babeltrace/ctf-ir/trace.h>
 #include <babeltrace/graph/graph-internal.h>
 #include <babeltrace/graph/notification-event-internal.h>
+#include <babeltrace/graph/private-connection-private-notification-iterator.h>
 #include <babeltrace/types.h>
 #include <babeltrace/assert-internal.h>
 #include <babeltrace/assert-pre-internal.h>
@@ -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)) {
index fab8f25695a6acb2aa4ce6e7d7775079e44cb73d..6c7c6cf403818473a2a1189541289ee27681c53a 100644 (file)
@@ -29,6 +29,7 @@
 #include <babeltrace/ctf-ir/clock-value-internal.h>
 #include <babeltrace/graph/notification-internal.h>
 #include <babeltrace/graph/notification-inactivity-internal.h>
+#include <babeltrace/graph/private-connection-private-notification-iterator.h>
 #include <babeltrace/assert-pre-internal.h>
 
 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;
index 316eb61380a2a2486b01fb01986440f9ad8a3b02..c5c6a6e5afff3e1b3f7da70e8302e909960268e9 100644 (file)
@@ -35,6 +35,7 @@
 #include <babeltrace/ctf-ir/stream-internal.h>
 #include <babeltrace/graph/graph-internal.h>
 #include <babeltrace/graph/notification-packet-internal.h>
+#include <babeltrace/graph/private-connection-private-notification-iterator.h>
 #include <babeltrace/assert-internal.h>
 #include <babeltrace/assert-pre-internal.h>
 #include <babeltrace/object-internal.h>
@@ -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) {
index f82761952171bd40f968662fc5fc138a4d113ae7..c9e694311b74081321c881ae0764c98766fb36d9 100644 (file)
@@ -32,6 +32,7 @@
 #include <babeltrace/ctf-ir/stream-internal.h>
 #include <babeltrace/ctf-ir/stream-class.h>
 #include <babeltrace/graph/notification-stream-internal.h>
+#include <babeltrace/graph/private-connection-private-notification-iterator.h>
 #include <babeltrace/assert-internal.h>
 #include <inttypes.h>
 
@@ -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;
index 8a5089f0a43257f38313277eae3f3b59d4f02938..37317a0176e5f10ba5474c708d87152b4a697dcf 100644 (file)
@@ -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);
 
index 33bd6fafebe6342f82103b40bcdf67e6e09d02f3..fe6f7c54ce8aebfe21a36cff485db3e0b43154a5 100644 (file)
@@ -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);
 
 /**
index d51bf1095bf8397687f3ffc6067098e13c5c18a9..2af4d177173b63a8ea6683bb1e0ad7a6bb1d91b9 100644 (file)
@@ -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:
index be035606e293870757bda19f6dc586b4364a9f89..13c6e8409bc504af3281f4b360c15c3d8f3bdbef 100644 (file)
@@ -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);
 
index 4cd70a21c174e2bd9d0ea5c4b4ab5073935940fb..59a7bcab592000f46a80bc3b0b09a9cbdf772286 100644 (file)
@@ -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;
index 534cb6b513cc2ec7afeaa6a485970d31e31ecc3a..101d427e704a11bc233e2ad4a74604b283361013 100644 (file)
@@ -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;
index 3bf57ef6a70e73bd42ad8bcad9b4b4521b94e43b..8cb9539cdbb9bd06d70f2f923964306f7db03d43 100644 (file)
@@ -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:
index d451140821a8cf53215cb5a50e232128993166c5..e70e51ea320d2944e2f3ac7346b6d03fd67c9833 100644 (file)
@@ -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);
 }
 
index 170523138ff4391f965ce4912c81ff89cbc51800..73f51e76660fb75d887f61d6e50a0deabc46f4e1 100644 (file)
@@ -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 {
This page took 0.039936 seconds and 4 git commands to generate.