connection.c: refuse to create a notif. iter. when the graph is canceled
[babeltrace.git] / lib / graph / connection.c
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.025558 seconds and 4 git commands to generate.