connection.c: refuse to create a notif. iter. when the graph is canceled
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 7 Jun 2017 22:03:54 +0000 (18:03 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 9 Jun 2017 21:03:27 +0000 (17:03 -0400)
It is useless to create a notification iterator from a connection which
belongs to a canceled graph.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/babeltrace/graph/connection-internal.h
lib/graph/connection.c

index 13e7d9ee65ad95aa0460819131a9e0dfb3b83347..fb4f668f36c040c8bfb62cf4da545239aa8f65df 100644 (file)
@@ -83,6 +83,13 @@ BT_HIDDEN
 void bt_connection_remove_iterator(struct bt_connection *conn,
                struct bt_notification_iterator *iterator);
 
+static inline
+struct bt_graph *bt_connection_borrow_graph(struct bt_connection *conn)
+{
+       assert(conn);
+       return (void *) conn->base.parent;
+}
+
 static inline
 enum bt_connection_status
 bt_connection_status_from_notification_iterator_status(
index 17cefd9c2956d5e48e04cc86190e740778d2cb68..72bbb852c0afc76f7a0b8214eb984d6cd84af971 100644 (file)
@@ -303,12 +303,23 @@ bt_private_connection_create_notification_iterator(
                goto end;
        }
 
-       if (!notification_types) {
-               BT_LOGD_STR("No notification types: subscribing to all notifications.");
-               notification_types = all_notif_types;
+       connection = bt_connection_from_private(private_connection);
+
+       if (bt_graph_is_canceled(bt_connection_borrow_graph(connection))) {
+               BT_LOGW("Cannot create notification iterator from connection: "
+                       "connection's graph is canceled: "
+                       "conn-addr=%p, upstream-port-addr=%p, "
+                       "upstream-port-name=\"%s\", upstream-comp-addr=%p, "
+                       "upstream-comp-name=\"%s\", graph-addr=%p",
+                       connection, connection->upstream_port,
+                       bt_port_get_name(connection->upstream_port),
+                       upstream_component,
+                       bt_component_get_name(upstream_component),
+                       bt_connection_borrow_graph(connection));
+               status = BT_CONNECTION_STATUS_GRAPH_IS_CANCELED;
+               goto end;
        }
 
-       connection = bt_connection_from_private(private_connection);
        if (bt_connection_is_ended(connection)) {
                BT_LOGW("Invalid parameter: connection is ended: "
                        "conn-addr=%p", connection);
@@ -316,6 +327,11 @@ bt_private_connection_create_notification_iterator(
                goto end;
        }
 
+       if (!notification_types) {
+               BT_LOGD_STR("No notification types: subscribing to all notifications.");
+               notification_types = all_notif_types;
+       }
+
        upstream_port = connection->upstream_port;
        assert(upstream_port);
        upstream_component = bt_port_get_component(upstream_port);
This page took 0.027043 seconds and 4 git commands to generate.