Make bt_private_connection_create_notification_iterator() return a status code
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 7 Jun 2017 21:45:59 +0000 (17:45 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 9 Jun 2017 21:03:27 +0000 (17:03 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
14 files changed:
include/babeltrace/graph/connection-internal.h
include/babeltrace/graph/connection.h
include/babeltrace/graph/notification-iterator-internal.h
include/babeltrace/graph/private-connection.h
lib/graph/connection.c
lib/graph/iterator.c
plugins/ctf/fs-sink/writer.c
plugins/lttng-utils/plugin.c
plugins/text/pretty/pretty.c
plugins/utils/dummy/dummy.c
plugins/utils/muxer/muxer.c
plugins/utils/trimmer/iterator.c
tests/lib/test_bt_notification_iterator.c
tests/plugins/test-utils-muxer.c

index 2a85296831089a06e3f46bc1d4326b5efbca7abd..13e7d9ee65ad95aa0460819131a9e0dfb3b83347 100644 (file)
@@ -28,6 +28,7 @@
  */
 
 #include <babeltrace/graph/connection.h>
  */
 
 #include <babeltrace/graph/connection.h>
+#include <babeltrace/graph/notification-iterator.h>
 #include <babeltrace/graph/private-connection.h>
 #include <babeltrace/object-internal.h>
 
 #include <babeltrace/graph/private-connection.h>
 #include <babeltrace/object-internal.h>
 
@@ -82,4 +83,35 @@ BT_HIDDEN
 void bt_connection_remove_iterator(struct bt_connection *conn,
                struct bt_notification_iterator *iterator);
 
 void bt_connection_remove_iterator(struct bt_connection *conn,
                struct bt_notification_iterator *iterator);
 
+static inline
+enum bt_connection_status
+bt_connection_status_from_notification_iterator_status(
+               enum bt_notification_iterator_status iter_status)
+{
+       switch (iter_status) {
+       case BT_NOTIFICATION_ITERATOR_STATUS_CANCELED:
+               return BT_CONNECTION_STATUS_ERROR;
+       case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN:
+               return BT_CONNECTION_STATUS_ERROR;
+       case BT_NOTIFICATION_ITERATOR_STATUS_END:
+               return BT_CONNECTION_STATUS_ERROR;
+       case BT_NOTIFICATION_ITERATOR_STATUS_OK:
+               return BT_CONNECTION_STATUS_OK;
+       case BT_NOTIFICATION_ITERATOR_STATUS_INVALID:
+               return BT_CONNECTION_STATUS_INVALID;
+       case BT_NOTIFICATION_ITERATOR_STATUS_ERROR:
+               return BT_CONNECTION_STATUS_ERROR;
+       case BT_NOTIFICATION_ITERATOR_STATUS_NOMEM:
+               return BT_CONNECTION_STATUS_NOMEM;
+       case BT_NOTIFICATION_ITERATOR_STATUS_UNSUPPORTED:
+               return BT_CONNECTION_STATUS_ERROR;
+       default:
+#ifdef BT_LOGF
+               BT_LOGF("Unknown notification iterator status: status=%d",
+                       iter_status);
+#endif
+               abort();
+       }
+}
+
 #endif /* BABELTRACE_COMPONENT_CONNECTION_INTERNAL_H */
 #endif /* BABELTRACE_COMPONENT_CONNECTION_INTERNAL_H */
index 60b9eef81c83a3a3080c84894e29b852bec6b6c9..566d5182964d6d89862a90181b22111e7a621046 100644 (file)
@@ -27,6 +27,8 @@
  * SOFTWARE.
  */
 
  * SOFTWARE.
  */
 
+#include <babeltrace/types.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -34,6 +36,15 @@ extern "C" {
 struct bt_component;
 struct bt_connection;
 
 struct bt_component;
 struct bt_connection;
 
+enum bt_connection_status {
+       BT_CONNECTION_STATUS_GRAPH_IS_CANCELED = 125,
+       BT_CONNECTION_STATUS_OK = 0,
+       BT_CONNECTION_STATUS_INVALID = -22,
+       BT_CONNECTION_STATUS_ERROR = -1,
+       BT_CONNECTION_STATUS_NOMEM = -12,
+       BT_CONNECTION_STATUS_IS_ENDED = 104,
+};
+
 /* Returns the "downstream" input port. */
 extern struct bt_port *bt_connection_get_downstream_port(
                struct bt_connection *connection);
 /* Returns the "downstream" input port. */
 extern struct bt_port *bt_connection_get_downstream_port(
                struct bt_connection *connection);
index f54547442b805764d44c964b6651875869bcd868..b7aafe0160f0927a503b947c71cd5623ed0b66d4 100644 (file)
@@ -132,18 +132,13 @@ bt_private_notification_iterator_from_notification_iterator(
        return (void *) notification_iterator;
 }
 
        return (void *) notification_iterator;
 }
 
-/**
- * Allocate a notification iterator.
- *
- * @param component            Component instance
- * @returns                    A notification iterator instance
- */
 BT_HIDDEN
 BT_HIDDEN
-struct bt_notification_iterator *bt_notification_iterator_create(
-               struct bt_component *upstream_component,
+enum bt_connection_status bt_notification_iterator_create(
+               struct bt_component *upstream_comp,
                struct bt_port *upstream_port,
                const enum bt_notification_type *notification_types,
                struct bt_port *upstream_port,
                const enum bt_notification_type *notification_types,
-               struct bt_connection *connection);
+               struct bt_connection *connection,
+               struct bt_notification_iterator **iterator);
 
 BT_HIDDEN
 void bt_notification_iterator_finalize(
 
 BT_HIDDEN
 void bt_notification_iterator_finalize(
index 59db640ee271aa95f9d6307db94f159c8fa3ab90..ea44d932481f1fec2243a7b41a04d8a4250e4a87 100644 (file)
@@ -23,6 +23,7 @@
  * SOFTWARE.
  */
 
  * SOFTWARE.
  */
 
+#include <babeltrace/graph/connection.h>
 #include <babeltrace/graph/notification.h>
 
 #ifdef __cplusplus
 #include <babeltrace/graph/notification.h>
 
 #ifdef __cplusplus
@@ -36,10 +37,11 @@ struct bt_private_connection;
 struct bt_connection *bt_connection_from_private_connection(
                struct bt_private_connection *private_connection);
 
 struct bt_connection *bt_connection_from_private_connection(
                struct bt_private_connection *private_connection);
 
-extern struct bt_notification_iterator *
+extern enum bt_connection_status
 bt_private_connection_create_notification_iterator(
                struct bt_private_connection *private_connection,
 bt_private_connection_create_notification_iterator(
                struct bt_private_connection *private_connection,
-               const enum bt_notification_type *notification_types);
+               const enum bt_notification_type *notification_types,
+               struct bt_notification_iterator **iterator);
 
 #ifdef __cplusplus
 }
 
 #ifdef __cplusplus
 }
index a13bce3e55e2d3114aaf374891897eace082eb59..c7e32c071bd4d97a6641ca51038058c1883e55c5 100644 (file)
@@ -272,10 +272,11 @@ struct bt_port *bt_connection_get_downstream_port(
        return connection ? bt_get(connection->downstream_port) : NULL;
 }
 
        return connection ? bt_get(connection->downstream_port) : NULL;
 }
 
-struct bt_notification_iterator *
+enum bt_connection_status
 bt_private_connection_create_notification_iterator(
                struct bt_private_connection *private_connection,
 bt_private_connection_create_notification_iterator(
                struct bt_private_connection *private_connection,
-               const enum bt_notification_type *notification_types)
+               const enum bt_notification_type *notification_types,
+               struct bt_notification_iterator **user_iterator)
 {
        enum bt_component_class_type upstream_comp_class_type;
        struct bt_notification_iterator *iterator = NULL;
 {
        enum bt_component_class_type upstream_comp_class_type;
        struct bt_notification_iterator *iterator = NULL;
@@ -284,6 +285,7 @@ bt_private_connection_create_notification_iterator(
        struct bt_component_class *upstream_comp_class = NULL;
        struct bt_connection *connection = NULL;
        bt_component_class_notification_iterator_init_method init_method = NULL;
        struct bt_component_class *upstream_comp_class = NULL;
        struct bt_connection *connection = NULL;
        bt_component_class_notification_iterator_init_method init_method = NULL;
+       enum bt_connection_status status;
        static const enum bt_notification_type all_notif_types[] = {
                BT_NOTIFICATION_TYPE_ALL,
                BT_NOTIFICATION_TYPE_SENTINEL,
        static const enum bt_notification_type all_notif_types[] = {
                BT_NOTIFICATION_TYPE_ALL,
                BT_NOTIFICATION_TYPE_SENTINEL,
@@ -291,7 +293,14 @@ bt_private_connection_create_notification_iterator(
 
        if (!private_connection) {
                BT_LOGW_STR("Invalid parameter: private connection is NULL.");
 
        if (!private_connection) {
                BT_LOGW_STR("Invalid parameter: private connection is NULL.");
-               goto error;
+               status = BT_CONNECTION_STATUS_INVALID;
+               goto end;
+       }
+
+       if (!user_iterator) {
+               BT_LOGW_STR("Invalid parameter: notification iterator pointer is NULL.");
+               status = BT_CONNECTION_STATUS_INVALID;
+               goto end;
        }
 
        if (!notification_types) {
        }
 
        if (!notification_types) {
@@ -300,10 +309,11 @@ bt_private_connection_create_notification_iterator(
        }
 
        connection = bt_connection_from_private(private_connection);
        }
 
        connection = bt_connection_from_private(private_connection);
-       if (!connection->upstream_port || !connection->downstream_port) {
+       if (bt_connection_is_ended(connection)) {
                BT_LOGW("Invalid parameter: connection is ended: "
                        "conn-addr=%p", connection);
                BT_LOGW("Invalid parameter: connection is ended: "
                        "conn-addr=%p", connection);
-               goto error;
+               status = BT_CONNECTION_STATUS_IS_ENDED;
+               goto end;
        }
 
        upstream_port = connection->upstream_port;
        }
 
        upstream_port = connection->upstream_port;
@@ -320,20 +330,13 @@ bt_private_connection_create_notification_iterator(
                upstream_component, bt_component_get_name(upstream_component));
        upstream_comp_class_type =
                bt_component_get_class_type(upstream_component);
                upstream_component, bt_component_get_name(upstream_component));
        upstream_comp_class_type =
                bt_component_get_class_type(upstream_component);
-       if (upstream_comp_class_type != BT_COMPONENT_CLASS_TYPE_SOURCE &&
-                       upstream_comp_class_type != BT_COMPONENT_CLASS_TYPE_FILTER) {
-               /* Unsupported operation. */
-               BT_LOGW("Upstream component's class is not a source or filter component class: "
-                       "comp-class-type=%s",
-                       bt_component_class_type_string(upstream_comp_class_type));
-               goto error;
-       }
-
-       iterator = bt_notification_iterator_create(upstream_component,
-               upstream_port, notification_types, connection);
-       if (!iterator) {
+       assert(upstream_comp_class_type == BT_COMPONENT_CLASS_TYPE_SOURCE ||
+                       upstream_comp_class_type == BT_COMPONENT_CLASS_TYPE_FILTER);
+       status = bt_notification_iterator_create(upstream_component,
+               upstream_port, notification_types, connection, &iterator);
+       if (status != BT_CONNECTION_STATUS_OK) {
                BT_LOGW("Cannot create notification iterator from connection.");
                BT_LOGW("Cannot create notification iterator from connection.");
-               goto error;
+               goto end;
        }
 
        switch (upstream_comp_class_type) {
        }
 
        switch (upstream_comp_class_type) {
@@ -355,22 +358,26 @@ bt_private_connection_create_notification_iterator(
        }
        default:
                /* Unreachable. */
        }
        default:
                /* Unreachable. */
+               BT_LOGF("Unknown component class type: type=%d",
+                       upstream_comp_class_type);
                abort();
        }
 
        if (init_method) {
                abort();
        }
 
        if (init_method) {
-               enum bt_notification_iterator_status status;
+               enum bt_notification_iterator_status iter_status;
 
                BT_LOGD("Calling user's initialization method: iter-addr=%p",
                        iterator);
 
                BT_LOGD("Calling user's initialization method: iter-addr=%p",
                        iterator);
-               status = init_method(
+               iter_status = init_method(
                        bt_private_notification_iterator_from_notification_iterator(iterator),
                        bt_private_port_from_port(upstream_port));
                BT_LOGD("User method returned: status=%s",
                        bt_private_notification_iterator_from_notification_iterator(iterator),
                        bt_private_port_from_port(upstream_port));
                BT_LOGD("User method returned: status=%s",
-                       bt_notification_iterator_status_string(status));
-               if (status < 0) {
+                       bt_notification_iterator_status_string(iter_status));
+               if (iter_status != BT_NOTIFICATION_ITERATOR_STATUS_OK) {
                        BT_LOGW_STR("Initialization method failed.");
                        BT_LOGW_STR("Initialization method failed.");
-                       goto error;
+                       status = bt_connection_status_from_notification_iterator_status(
+                               iter_status);
+                       goto end;
                }
        }
 
                }
        }
 
@@ -383,14 +390,12 @@ bt_private_connection_create_notification_iterator(
                bt_port_get_name(connection->upstream_port),
                upstream_component, bt_component_get_name(upstream_component),
                iterator);
                bt_port_get_name(connection->upstream_port),
                upstream_component, bt_component_get_name(upstream_component),
                iterator);
-       goto end;
-
-error:
-       BT_PUT(iterator);
+       BT_MOVE(*user_iterator, iterator);
 
 end:
        bt_put(upstream_component);
 
 end:
        bt_put(upstream_component);
-       return iterator;
+       bt_put(iterator);
+       return status;
 }
 
 BT_HIDDEN
 }
 
 BT_HIDDEN
index 07eaa1fd146d42d8702c897ec6020bf0f95a46c1..6d6058f5225eafcda2946bc9d4fc77352855a2b3 100644 (file)
@@ -33,6 +33,7 @@
 #include <babeltrace/ctf-ir/event-internal.h>
 #include <babeltrace/ctf-ir/packet-internal.h>
 #include <babeltrace/ctf-ir/stream-internal.h>
 #include <babeltrace/ctf-ir/event-internal.h>
 #include <babeltrace/ctf-ir/packet-internal.h>
 #include <babeltrace/ctf-ir/stream-internal.h>
+#include <babeltrace/graph/connection.h>
 #include <babeltrace/graph/connection-internal.h>
 #include <babeltrace/graph/component.h>
 #include <babeltrace/graph/component-source-internal.h>
 #include <babeltrace/graph/connection-internal.h>
 #include <babeltrace/graph/component.h>
 #include <babeltrace/graph/component-source-internal.h>
@@ -513,12 +514,14 @@ end:
 }
 
 BT_HIDDEN
 }
 
 BT_HIDDEN
-struct bt_notification_iterator *bt_notification_iterator_create(
+enum bt_connection_status bt_notification_iterator_create(
                struct bt_component *upstream_comp,
                struct bt_port *upstream_port,
                const enum bt_notification_type *notification_types,
                struct bt_component *upstream_comp,
                struct bt_port *upstream_port,
                const enum bt_notification_type *notification_types,
-               struct bt_connection *connection)
+               struct bt_connection *connection,
+               struct bt_notification_iterator **user_iterator)
 {
 {
+       enum bt_connection_status status = BT_CONNECTION_STATUS_OK;
        enum bt_component_class_type type;
        struct bt_notification_iterator *iterator = NULL;
 
        enum bt_component_class_type type;
        struct bt_notification_iterator *iterator = NULL;
 
@@ -526,6 +529,7 @@ struct bt_notification_iterator *bt_notification_iterator_create(
        assert(upstream_port);
        assert(notification_types);
        assert(bt_port_is_connected(upstream_port));
        assert(upstream_port);
        assert(notification_types);
        assert(bt_port_is_connected(upstream_port));
+       assert(user_iterator);
        BT_LOGD("Creating notification iterator: "
                "upstream-comp-addr=%p, upstream-comp-name=\"%s\", "
                "upstream-port-addr=%p, upstream-port-name=\"%s\", "
        BT_LOGD("Creating notification iterator: "
                "upstream-comp-addr=%p, upstream-comp-name=\"%s\", "
                "upstream-port-addr=%p, upstream-port-name=\"%s\", "
@@ -539,7 +543,8 @@ struct bt_notification_iterator *bt_notification_iterator_create(
        iterator = g_new0(struct bt_notification_iterator, 1);
        if (!iterator) {
                BT_LOGE_STR("Failed to allocate one notification iterator.");
        iterator = g_new0(struct bt_notification_iterator, 1);
        if (!iterator) {
                BT_LOGE_STR("Failed to allocate one notification iterator.");
-               goto error;
+               status = BT_CONNECTION_STATUS_NOMEM;
+               goto end;
        }
 
        bt_object_init(iterator, bt_notification_iterator_destroy);
        }
 
        bt_object_init(iterator, bt_notification_iterator_destroy);
@@ -547,26 +552,30 @@ struct bt_notification_iterator *bt_notification_iterator_create(
        if (create_subscription_mask_from_notification_types(iterator,
                        notification_types)) {
                BT_LOGW_STR("Cannot create subscription mask from notification types.");
        if (create_subscription_mask_from_notification_types(iterator,
                        notification_types)) {
                BT_LOGW_STR("Cannot create subscription mask from notification types.");
-               goto error;
+               status = BT_CONNECTION_STATUS_INVALID;
+               goto end;
        }
 
        iterator->stream_states = g_hash_table_new_full(g_direct_hash,
                g_direct_equal, NULL, (GDestroyNotify) destroy_stream_state);
        if (!iterator->stream_states) {
                BT_LOGE_STR("Failed to allocate a GHashTable.");
        }
 
        iterator->stream_states = g_hash_table_new_full(g_direct_hash,
                g_direct_equal, NULL, (GDestroyNotify) destroy_stream_state);
        if (!iterator->stream_states) {
                BT_LOGE_STR("Failed to allocate a GHashTable.");
-               goto error;
+               status = BT_CONNECTION_STATUS_NOMEM;
+               goto end;
        }
 
        iterator->queue = g_queue_new();
        if (!iterator->queue) {
                BT_LOGE_STR("Failed to allocate a GQueue.");
        }
 
        iterator->queue = g_queue_new();
        if (!iterator->queue) {
                BT_LOGE_STR("Failed to allocate a GQueue.");
-               goto error;
+               status = BT_CONNECTION_STATUS_NOMEM;
+               goto end;
        }
 
        iterator->actions = g_array_new(FALSE, FALSE, sizeof(struct action));
        if (!iterator->actions) {
                BT_LOGE_STR("Failed to allocate a GArray.");
        }
 
        iterator->actions = g_array_new(FALSE, FALSE, sizeof(struct action));
        if (!iterator->actions) {
                BT_LOGE_STR("Failed to allocate a GArray.");
-               goto error;
+               status = BT_CONNECTION_STATUS_NOMEM;
+               goto end;
        }
 
        iterator->upstream_component = upstream_comp;
        }
 
        iterator->upstream_component = upstream_comp;
@@ -580,13 +589,11 @@ struct bt_notification_iterator *bt_notification_iterator_create(
                upstream_comp, bt_component_get_name(upstream_comp),
                upstream_port, bt_port_get_name(upstream_port),
                connection, iterator);
                upstream_comp, bt_component_get_name(upstream_comp),
                upstream_port, bt_port_get_name(upstream_port),
                connection, iterator);
-       goto end;
-
-error:
-       BT_PUT(iterator);
+       BT_MOVE(*user_iterator, iterator);
 
 end:
 
 end:
-       return iterator;
+       bt_put(iterator);
+       return status;
 }
 
 void *bt_private_notification_iterator_get_user_data(
 }
 
 void *bt_private_notification_iterator_get_user_data(
index 1bc5966deac4e4fbca37cea34d926a0078553f80..1e8aaf760e0c83c14e78073bbb01d34d87811822 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <babeltrace/ctf-ir/packet.h>
 #include <babeltrace/plugin/plugin-dev.h>
 
 #include <babeltrace/ctf-ir/packet.h>
 #include <babeltrace/plugin/plugin-dev.h>
+#include <babeltrace/graph/connection.h>
 #include <babeltrace/graph/component.h>
 #include <babeltrace/graph/private-component.h>
 #include <babeltrace/graph/component-sink.h>
 #include <babeltrace/graph/component.h>
 #include <babeltrace/graph/private-component.h>
 #include <babeltrace/graph/component-sink.h>
@@ -213,6 +214,7 @@ void writer_component_port_connected(
 {
        struct bt_private_connection *connection;
        struct writer_component *writer;
 {
        struct bt_private_connection *connection;
        struct writer_component *writer;
+       enum bt_connection_status conn_status;
        static const enum bt_notification_type notif_types[] = {
                BT_NOTIFICATION_TYPE_EVENT,
                BT_NOTIFICATION_TYPE_PACKET_BEGIN,
        static const enum bt_notification_type notif_types[] = {
                BT_NOTIFICATION_TYPE_EVENT,
                BT_NOTIFICATION_TYPE_PACKET_BEGIN,
@@ -227,11 +229,9 @@ void writer_component_port_connected(
        assert(!writer->input_iterator);
        connection = bt_private_port_get_private_connection(self_port);
        assert(connection);
        assert(!writer->input_iterator);
        connection = bt_private_port_get_private_connection(self_port);
        assert(connection);
-       writer->input_iterator =
-               bt_private_connection_create_notification_iterator(connection,
-                       notif_types);
-
-       if (!writer->input_iterator) {
+       conn_status = bt_private_connection_create_notification_iterator(
+               connection, notif_types, &writer->input_iterator);
+       if (conn_status != BT_CONNECTION_STATUS_OK) {
                writer->error = true;
        }
 
                writer->error = true;
        }
 
index fb00dee315b64ee4c650fa6357a7233fd3cb2c11..ec9c70adbf81d92cdae90b0149c7255b8d3796fa 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <babeltrace/graph/notification-iterator.h>
 #include <babeltrace/graph/private-notification-iterator.h>
 
 #include <babeltrace/graph/notification-iterator.h>
 #include <babeltrace/graph/private-notification-iterator.h>
+#include <babeltrace/graph/connection.h>
 #include <babeltrace/graph/notification.h>
 #include <babeltrace/graph/notification-event.h>
 #include <babeltrace/graph/notification-stream.h>
 #include <babeltrace/graph/notification.h>
 #include <babeltrace/graph/notification-event.h>
 #include <babeltrace/graph/notification-stream.h>
@@ -275,6 +276,7 @@ enum bt_notification_iterator_status debug_info_iterator_init(
        enum bt_notification_iterator_status ret =
                BT_NOTIFICATION_ITERATOR_STATUS_OK;
        enum bt_notification_iterator_status it_ret;
        enum bt_notification_iterator_status ret =
                BT_NOTIFICATION_ITERATOR_STATUS_OK;
        enum bt_notification_iterator_status it_ret;
+       enum bt_connection_status conn_status;
        struct bt_private_connection *connection = NULL;
        struct bt_private_component *component =
                bt_private_notification_iterator_get_private_component(iterator);
        struct bt_private_connection *connection = NULL;
        struct bt_private_component *component =
                bt_private_notification_iterator_get_private_component(iterator);
@@ -307,10 +309,10 @@ enum bt_notification_iterator_status debug_info_iterator_init(
                goto end;
        }
 
                goto end;
        }
 
-       it_data->input_iterator = bt_private_connection_create_notification_iterator(
-                       connection, notif_types);
-       if (!it_data->input_iterator) {
-               ret = BT_NOTIFICATION_ITERATOR_STATUS_NOMEM;
+       conn_status = bt_private_connection_create_notification_iterator(
+                       connection, notif_types, &it_data->input_iterator);
+       if (conn_status != BT_CONNECTION_STATUS_OK) {
+               ret = BT_NOTIFICATION_ITERATOR_STATUS_ERROR;
                goto end;
        }
 
                goto end;
        }
 
index 3d4708672049e2d833a8066a6b9182ce7da00771..e8f89d3a38ee2d2901b3427a14507c1df197c776 100644 (file)
@@ -167,6 +167,7 @@ void pretty_port_connected(
                struct bt_private_port *self_port,
                struct bt_port *other_port)
 {
                struct bt_private_port *self_port,
                struct bt_port *other_port)
 {
+       enum bt_connection_status conn_status;
        struct bt_private_connection *connection;
        struct pretty_component *pretty;
        static const enum bt_notification_type notif_types[] = {
        struct bt_private_connection *connection;
        struct pretty_component *pretty;
        static const enum bt_notification_type notif_types[] = {
@@ -179,11 +180,9 @@ void pretty_port_connected(
        assert(!pretty->input_iterator);
        connection = bt_private_port_get_private_connection(self_port);
        assert(connection);
        assert(!pretty->input_iterator);
        connection = bt_private_port_get_private_connection(self_port);
        assert(connection);
-       pretty->input_iterator =
-               bt_private_connection_create_notification_iterator(connection,
-                       notif_types);
-
-       if (!pretty->input_iterator) {
+       conn_status = bt_private_connection_create_notification_iterator(
+               connection, notif_types, &pretty->input_iterator);
+       if (conn_status != BT_CONNECTION_STATUS_OK) {
                pretty->error = true;
        }
 
                pretty->error = true;
        }
 
index df2ddff9345408df2aca16fb676b8ef9d942a41f..c3434a59929b8f1c6b2d71d4f8cd7405f9d8de77 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include <babeltrace/plugin/plugin-dev.h>
  */
 
 #include <babeltrace/plugin/plugin-dev.h>
+#include <babeltrace/graph/connection.h>
 #include <babeltrace/graph/component.h>
 #include <babeltrace/graph/private-component.h>
 #include <babeltrace/graph/private-component-sink.h>
 #include <babeltrace/graph/component.h>
 #include <babeltrace/graph/private-component.h>
 #include <babeltrace/graph/private-component-sink.h>
@@ -97,14 +98,15 @@ void dummy_port_connected(
        struct dummy *dummy;
        struct bt_notification_iterator *iterator;
        struct bt_private_connection *connection;
        struct dummy *dummy;
        struct bt_notification_iterator *iterator;
        struct bt_private_connection *connection;
+       enum bt_connection_status conn_status;
 
        dummy = bt_private_component_get_user_data(component);
        assert(dummy);
        connection = bt_private_port_get_private_connection(self_port);
        assert(connection);
 
        dummy = bt_private_component_get_user_data(component);
        assert(dummy);
        connection = bt_private_port_get_private_connection(self_port);
        assert(connection);
-       iterator = bt_private_connection_create_notification_iterator(
-               connection, NULL);
-       if (!iterator) {
+       conn_status = bt_private_connection_create_notification_iterator(
+               connection, NULL, &iterator);
+       if (conn_status != BT_CONNECTION_STATUS_OK) {
                dummy->error = true;
                goto end;
        }
                dummy->error = true;
                goto end;
        }
index 30864edb4ceffbb3aba1dc4dc2ad7d927d6de326..47ffb866002018bdf5b5471ed6f7126fc355151c 100644 (file)
@@ -37,6 +37,7 @@
 #include <babeltrace/graph/private-connection.h>
 #include <babeltrace/graph/private-notification-iterator.h>
 #include <babeltrace/graph/private-port.h>
 #include <babeltrace/graph/private-connection.h>
 #include <babeltrace/graph/private-notification-iterator.h>
 #include <babeltrace/graph/private-port.h>
+#include <babeltrace/graph/connection.h>
 #include <plugins-common.h>
 #include <glib.h>
 #include <stdbool.h>
 #include <plugins-common.h>
 #include <glib.h>
 #include <stdbool.h>
@@ -336,6 +337,7 @@ struct bt_notification_iterator *create_notif_iter_on_input_port(
        struct bt_port *port = bt_port_from_private_port(priv_port);
        struct bt_notification_iterator *notif_iter = NULL;
        struct bt_private_connection *priv_conn = NULL;
        struct bt_port *port = bt_port_from_private_port(priv_port);
        struct bt_notification_iterator *notif_iter = NULL;
        struct bt_private_connection *priv_conn = NULL;
+       enum bt_connection_status conn_status;
 
        assert(ret);
        *ret = 0;
 
        assert(ret);
        *ret = 0;
@@ -351,9 +353,9 @@ struct bt_notification_iterator *create_notif_iter_on_input_port(
        // TODO: Advance the iterator to >= the time of the latest
        //       returned notification by the muxer notification
        //       iterator which creates it.
        // TODO: Advance the iterator to >= the time of the latest
        //       returned notification by the muxer notification
        //       iterator which creates it.
-       notif_iter = bt_private_connection_create_notification_iterator(
-               priv_conn, NULL);
-       if (!notif_iter) {
+       conn_status = bt_private_connection_create_notification_iterator(
+               priv_conn, NULL, &notif_iter);
+       if (conn_status != BT_CONNECTION_STATUS_OK) {
                *ret = -1;
                goto end;
        }
                *ret = -1;
                goto end;
        }
index 8241014d4fe678b9660ed40f053fcfd0207237e6..1e94b15ecc6d5a1a0e588f5fc8860f2522bf9174 100644 (file)
@@ -39,6 +39,7 @@
 #include <babeltrace/graph/private-port.h>
 #include <babeltrace/graph/private-connection.h>
 #include <babeltrace/graph/private-component.h>
 #include <babeltrace/graph/private-port.h>
 #include <babeltrace/graph/private-connection.h>
 #include <babeltrace/graph/private-component.h>
+#include <babeltrace/graph/connection.h>
 #include <babeltrace/ctf-ir/event.h>
 #include <babeltrace/ctf-ir/stream.h>
 #include <babeltrace/ctf-ir/stream-class.h>
 #include <babeltrace/ctf-ir/event.h>
 #include <babeltrace/ctf-ir/stream.h>
 #include <babeltrace/ctf-ir/stream-class.h>
@@ -85,6 +86,7 @@ enum bt_notification_iterator_status trimmer_iterator_init(
        enum bt_notification_iterator_status ret =
                BT_NOTIFICATION_ITERATOR_STATUS_OK;
        enum bt_notification_iterator_status it_ret;
        enum bt_notification_iterator_status ret =
                BT_NOTIFICATION_ITERATOR_STATUS_OK;
        enum bt_notification_iterator_status it_ret;
+       enum bt_connection_status conn_status;
        struct bt_private_port *input_port = NULL;
        struct bt_private_connection *connection = NULL;
        struct bt_private_component *component =
        struct bt_private_port *input_port = NULL;
        struct bt_private_connection *connection = NULL;
        struct bt_private_component *component =
@@ -110,11 +112,10 @@ enum bt_notification_iterator_status trimmer_iterator_init(
        connection = bt_private_port_get_private_connection(input_port);
        assert(connection);
 
        connection = bt_private_port_get_private_connection(input_port);
        assert(connection);
 
-       it_data->input_iterator =
-               bt_private_connection_create_notification_iterator(connection,
-                       notif_types);
-       if (!it_data->input_iterator) {
-               ret = BT_NOTIFICATION_ITERATOR_STATUS_NOMEM;
+       conn_status = bt_private_connection_create_notification_iterator(connection,
+                       notif_types, &it_data->input_iterator);
+       if (conn_status != BT_CONNECTION_STATUS_OK) {
+               ret = BT_NOTIFICATION_ITERATOR_STATUS_ERROR;
                goto end;
        }
 
                goto end;
        }
 
index 8dff7d0edbf9212313191002395a017b42404fd9..cbce6b4c965a00acef12aa469933640ae6307e5f 100644 (file)
@@ -38,6 +38,7 @@
 #include <babeltrace/graph/component-sink.h>
 #include <babeltrace/graph/component-source.h>
 #include <babeltrace/graph/component.h>
 #include <babeltrace/graph/component-sink.h>
 #include <babeltrace/graph/component-source.h>
 #include <babeltrace/graph/component.h>
+#include <babeltrace/graph/connection.h>
 #include <babeltrace/graph/graph.h>
 #include <babeltrace/graph/notification-event.h>
 #include <babeltrace/graph/notification-inactivity.h>
 #include <babeltrace/graph/graph.h>
 #include <babeltrace/graph/notification-event.h>
 #include <babeltrace/graph/notification-inactivity.h>
@@ -824,13 +825,13 @@ void sink_port_connected(struct bt_private_component *private_component,
                bt_private_port_get_private_connection(self_private_port);
        struct sink_user_data *user_data = bt_private_component_get_user_data(
                private_component);
                bt_private_port_get_private_connection(self_private_port);
        struct sink_user_data *user_data = bt_private_component_get_user_data(
                private_component);
+       enum bt_connection_status conn_status;
 
        assert(user_data);
        assert(priv_conn);
 
        assert(user_data);
        assert(priv_conn);
-       user_data->notif_iter =
-               bt_private_connection_create_notification_iterator(priv_conn,
-                       NULL);
-       assert(user_data->notif_iter);
+       conn_status = bt_private_connection_create_notification_iterator(
+               priv_conn, NULL, &user_data->notif_iter);
+       assert(conn_status == 0);
        bt_put(priv_conn);
 }
 
        bt_put(priv_conn);
 }
 
index 0045b0bf3d3998c329ec1e8f98f2607b3a7be7f2..6600a72e8f183caeb5fec509fa562d6e7e784ecf 100644 (file)
@@ -871,13 +871,13 @@ void sink_port_connected(struct bt_private_component *private_component,
                bt_private_port_get_private_connection(self_private_port);
        struct sink_user_data *user_data = bt_private_component_get_user_data(
                private_component);
                bt_private_port_get_private_connection(self_private_port);
        struct sink_user_data *user_data = bt_private_component_get_user_data(
                private_component);
+       enum bt_connection_status conn_status;
 
        assert(user_data);
        assert(priv_conn);
 
        assert(user_data);
        assert(priv_conn);
-       user_data->notif_iter =
-               bt_private_connection_create_notification_iterator(priv_conn,
-                       NULL);
-       assert(user_data->notif_iter);
+       conn_status = bt_private_connection_create_notification_iterator(
+               priv_conn, NULL, &user_data->notif_iter);
+       assert(conn_status == 0);
        bt_put(priv_conn);
 }
 
        bt_put(priv_conn);
 }
 
This page took 0.051505 seconds and 4 git commands to generate.