lib: do not allow port to be removed when message iterators are active
[babeltrace.git] / lib / graph / connection.c
index 5d0749135e118222e22e4b1d814ca0ee1257a432..d490c5dcf5f61b3ef14d7b4f8ea7fb5b89516ed6 100644 (file)
@@ -46,10 +46,10 @@ void destroy_connection(struct bt_object *obj)
        BT_LIB_LOGD("Destroying connection: %!+x", connection);
 
        /*
-        * Make sure that each message iterator which was created
-        * for this connection is finalized before we destroy it. Once a
-        * message iterator is finalized, all its method return
-        * NULL or the BT_MESSAGE_ITERATOR_STATUS_CANCELED status.
+        * Make sure that each message iterator which was created for
+        * this connection is finalized before we destroy it. Once a
+        * message iterator is finalized, all its method return NULL or
+        * the BT_MESSAGE_ITERATOR_STATUS_CANCELED status.
         *
         * Because connections are destroyed before components within a
         * graph, this ensures that message iterators are always
@@ -227,8 +227,12 @@ void bt_connection_end(struct bt_connection *conn, bool try_remove_from_graph)
        bt_object_put_ref(upstream_port);
 
        /*
-        * Because this connection is ended, finalize (cancel) each
-        * message iterator created from it.
+        * Because this connection is ended, finalize each message
+        * iterator created from it.
+        *
+        * In practice, this only happens when the connection is
+        * destroyed and not all its message iterators were finalized,
+        * which is on graph destruction.
         */
        for (i = 0; i < conn->iterators->len; i++) {
                struct bt_self_component_port_input_message_iterator *iterator =
@@ -236,7 +240,7 @@ void bt_connection_end(struct bt_connection *conn, bool try_remove_from_graph)
 
                BT_LIB_LOGD("Finalizing message iterator created by "
                        "this ended connection: %![iter-]+i", iterator);
-               bt_self_component_port_input_message_iterator_finalize(
+               bt_self_component_port_input_message_iterator_try_finalize(
                        iterator);
 
                /*
This page took 0.025648 seconds and 4 git commands to generate.