lib: remove unused _NO_SINK graph status
[babeltrace.git] / lib / graph / graph.c
index 49933d54931588dbd88ad7f6eddbc8f35bd6c38f..219ca277ae6a197ea4d2e604cd9730db35745ac4 100644 (file)
@@ -82,6 +82,9 @@ struct bt_graph_listener_ports_connected {
        do {                                                            \
                size_t i;                                               \
                                                                        \
+               if (!_listeners) {                                      \
+                       break;                                          \
+               }                                                       \
                for (i = 0; i < (_listeners)->len; i++) {               \
                        _type *listener =                               \
                                &g_array_index((_listeners), _type, i); \
@@ -408,7 +411,7 @@ enum bt_graph_status bt_graph_connect_ports(
        BT_ASSERT_PRE(!graph->canceled, "Graph is canceled: %!+g", graph);
        BT_ASSERT_PRE(
                graph->config_state == BT_GRAPH_CONFIGURATION_STATE_CONFIGURING,
-               "Graph is already configured: %!+g", graph);
+               "Graph is not in the \"configuring\" state: %!+g", graph);
        BT_ASSERT_PRE(!bt_port_is_connected(upstream_port),
                "Upstream port is already connected: %!+p", upstream_port);
        BT_ASSERT_PRE(!bt_port_is_connected(downstream_port),
@@ -543,6 +546,10 @@ enum bt_graph_status bt_graph_connect_ports(
        }
 
 end:
+       if (status != BT_GRAPH_STATUS_OK) {
+               graph->config_state = BT_GRAPH_CONFIGURATION_STATE_FAULTY;
+       }
+
        bt_object_put_ref(connection);
        (void) init_can_consume;
        bt_graph_set_can_consume(graph, init_can_consume);
@@ -680,9 +687,11 @@ enum bt_graph_status bt_graph_consume(struct bt_graph *graph)
        BT_ASSERT_PRE(!graph->canceled, "Graph is canceled: %!+g", graph);
        BT_ASSERT_PRE(graph->can_consume,
                "Cannot consume graph in its current state: %!+g", graph);
+       BT_ASSERT_PRE(graph->config_state != BT_GRAPH_CONFIGURATION_STATE_FAULTY,
+               "Graph is in a faulty state: %!+g", graph);
        bt_graph_set_can_consume(graph, false);
        status = bt_graph_configure(graph);
-       if (status) {
+       if (unlikely(status)) {
                /* bt_graph_configure() logs errors */
                goto end;
        }
@@ -702,9 +711,11 @@ enum bt_graph_status bt_graph_run(struct bt_graph *graph)
        BT_ASSERT_PRE(!graph->canceled, "Graph is canceled: %!+g", graph);
        BT_ASSERT_PRE(graph->can_consume,
                "Cannot consume graph in its current state: %!+g", graph);
+       BT_ASSERT_PRE(graph->config_state != BT_GRAPH_CONFIGURATION_STATE_FAULTY,
+               "Graph is in a faulty state: %!+g", graph);
        bt_graph_set_can_consume(graph, false);
        status = bt_graph_configure(graph);
-       if (status) {
+       if (unlikely(status)) {
                /* bt_graph_configure() logs errors */
                goto end;
        }
@@ -741,8 +752,6 @@ enum bt_graph_status bt_graph_run(struct bt_graph *graph)
                        if (graph->sinks_to_consume->length > 1) {
                                status = BT_GRAPH_STATUS_OK;
                        }
-               } else if (status == BT_GRAPH_STATUS_NO_SINK) {
-                       goto end;
                }
        } while (status == BT_GRAPH_STATUS_OK);
 
@@ -1249,7 +1258,7 @@ enum bt_graph_status add_component_with_init_method_data(
        BT_ASSERT_PRE(!graph->canceled, "Graph is canceled: %!+g", graph);
        BT_ASSERT_PRE(
                graph->config_state == BT_GRAPH_CONFIGURATION_STATE_CONFIGURING,
-               "Graph is already configured: %!+g", graph);
+               "Graph is not in the \"configuring\" state: %!+g", graph);
        BT_ASSERT_PRE(!component_name_exists(graph, name),
                "Duplicate component name: %!+g, name=\"%s\"", graph, name);
        BT_ASSERT_PRE(!params || bt_value_is_map(params),
@@ -1287,6 +1296,7 @@ enum bt_graph_status add_component_with_init_method_data(
         */
        g_ptr_array_add(graph->components, component);
        bt_component_set_graph(component, graph);
+       bt_value_freeze(params);
 
        if (init_method) {
                BT_LOGD_STR("Calling user's initialization method.");
@@ -1335,6 +1345,10 @@ enum bt_graph_status add_component_with_init_method_data(
        }
 
 end:
+       if (graph_status != BT_GRAPH_STATUS_OK) {
+               graph->config_state = BT_GRAPH_CONFIGURATION_STATE_FAULTY;
+       }
+
        bt_object_put_ref(component);
        bt_object_put_ref(new_params);
        (void) init_can_consume;
This page took 0.024455 seconds and 4 git commands to generate.