lib: fully configure graph (add components, connect ports), then run
[babeltrace.git] / lib / graph / connection.c
index 5d0749135e118222e22e4b1d814ca0ee1257a432..965c5eaa050996613544ce7a7f8c540207ac6154 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
@@ -157,11 +157,8 @@ end:
 BT_HIDDEN
 void bt_connection_end(struct bt_connection *conn, bool try_remove_from_graph)
 {
-       struct bt_component *downstream_comp = NULL;
-       struct bt_component *upstream_comp = NULL;
        struct bt_port *downstream_port = conn->downstream_port;
        struct bt_port *upstream_port = conn->upstream_port;
-       struct bt_graph *graph = bt_connection_borrow_graph(conn);
        size_t i;
 
        BT_LIB_LOGD("Ending connection: %!+x, try-remove-from-graph=%d",
@@ -179,8 +176,6 @@ void bt_connection_end(struct bt_connection *conn, bool try_remove_from_graph)
        if (downstream_port) {
                BT_LIB_LOGD("Disconnecting connection's downstream port: %!+p",
                        downstream_port);
-               downstream_comp = bt_port_borrow_component_inline(
-                       downstream_port);
                bt_port_set_connection(downstream_port, NULL);
                conn->downstream_port = NULL;
        }
@@ -188,37 +183,10 @@ void bt_connection_end(struct bt_connection *conn, bool try_remove_from_graph)
        if (upstream_port) {
                BT_LIB_LOGD("Disconnecting connection's upstream port: %!+p",
                        upstream_port);
-               upstream_comp = bt_port_borrow_component_inline(
-                       upstream_port);
                bt_port_set_connection(upstream_port, NULL);
                conn->upstream_port = NULL;
        }
 
-       if (downstream_comp && conn->notified_downstream_port_connected &&
-                       !conn->notified_downstream_port_disconnected) {
-               /* bt_component_port_disconnected() logs details */
-               bt_component_port_disconnected(downstream_comp,
-                       downstream_port);
-               conn->notified_downstream_port_disconnected = true;
-       }
-
-       if (upstream_comp && conn->notified_upstream_port_connected &&
-                       !conn->notified_upstream_port_disconnected) {
-               /* bt_component_port_disconnected() logs details */
-               bt_component_port_disconnected(upstream_comp, upstream_port);
-               conn->notified_upstream_port_disconnected = true;
-       }
-
-       BT_ASSERT(graph);
-
-       if (conn->notified_graph_ports_connected &&
-                       !conn->notified_graph_ports_disconnected) {
-               /* bt_graph_notify_ports_disconnected() logs details */
-               bt_graph_notify_ports_disconnected(graph, upstream_comp,
-                       downstream_comp, upstream_port, downstream_port);
-               conn->notified_graph_ports_disconnected = true;
-       }
-
        /*
         * It is safe to put the local port references now that we don't
         * need them anymore. This could indeed destroy them.
@@ -227,8 +195,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 +208,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.030232 seconds and 4 git commands to generate.