Fix: lib: usage of output port message iterator
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 13 May 2019 18:01:22 +0000 (14:01 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 5 Jun 2019 17:47:34 +0000 (13:47 -0400)
Fix some issues relate to output port message iterator usage.

The first encountered issue when trying to create one such iterator is:

    05-13 13:51:20.845 14995 14995 F MSG-ITER bt_self_component_port_input_message_iterator_create@iterator.c:444 Graph is not configured: addr=0x612000000640, is-canceled=0, can-consume=0, config-state=BT_GRAPH_CONFIGURATION_STATE_CONFIGURING, comp-count=2, conn-count=1, en-pool-size=0, en-pool-cap=0, pbn-pool-size=0, pbn-pool-cap=0, pen-pool-size=0, pen-pool-cap=0

The problem is that the colander is trying to create an input iterator on its
input port in the "port connected" callback, which is before the graph is
configured.  This is not a valid thing to do anymore, so change it to create
the input iterator during the "graph is configured" step.

The next issue we face is then:

    05-13 14:00:01.903 21344 21344 W COLANDER colander_consume@component-class-sink-colander.c:142 Trying to consume without an upstream message iterator: comp-addr=0x60c0000028c0, c
omp-name="colander-36ac3409-b1a8-4d60-ab1f-4fdf341a8fb1", comp-class-type=BT_COMPONENT_CLASS_TYPE_SINK, comp-class-name="colander", comp-class-partial-descr="", comp-class-is-frozen=1, comp-input-port-count=1, comp-output-port-count=0

This is because the "graph is configured" callback is never invoked,
the reason being that bt_port_output_message_iterator_create just sets
the graph's config state field directly, rather than calling
bt_graph_configure.

Change-Id: Idbf873912ea5d116f0b011639177e57aa78e6759
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1297
Tested-by: jenkins
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
lib/graph/component-class-sink-colander.c
lib/graph/iterator.c

index 9a70f105218172060aa6f39d2ae3ce149abb53bb..7f3cfeca6329f94604cc4f9127d4bd6f782c7fe6 100644 (file)
@@ -94,16 +94,18 @@ void colander_finalize(struct bt_self_component_sink *self_comp)
 }
 
 static
-enum bt_self_component_status colander_input_port_connected(
-               struct bt_self_component_sink *self_comp,
-               struct bt_self_component_port_input *self_port,
-               const struct bt_port_output *other_port)
+enum bt_self_component_status colander_graph_is_configured(
+       bt_self_component_sink *self_comp)
 {
        enum bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
        struct bt_component_class_sink_colander_priv_data *colander_data =
                bt_self_component_get_data(
                        bt_self_component_sink_as_self_component(self_comp));
 
+       struct bt_self_component_port_input *self_port =
+               bt_self_component_sink_borrow_input_port_by_name(self_comp, "in");
+       BT_ASSERT(self_port);
+
        BT_ASSERT(colander_data);
        BT_OBJECT_PUT_REF_AND_RESET(colander_data->msg_iter);
        colander_data->msg_iter =
@@ -183,8 +185,8 @@ struct bt_component_class_sink *bt_component_class_sink_colander_get(void)
                colander_comp_cls, colander_init);
        (void) bt_component_class_sink_set_finalize_method(
                colander_comp_cls, colander_finalize);
-       (void) bt_component_class_sink_set_input_port_connected_method(
-               colander_comp_cls, colander_input_port_connected);
+       (void) bt_component_class_sink_set_graph_is_configured_method(
+               colander_comp_cls, colander_graph_is_configured);
 
 end:
        bt_object_get_ref(colander_comp_cls);
index 6a969826cc4da08a253d023360e01ead5851a99c..eba243739fdc07eeafcb0915f784936f884cb59b 100644 (file)
@@ -792,11 +792,14 @@ bt_port_output_message_iterator_create(struct bt_graph *graph,
         */
        bt_graph_set_can_consume(iterator->graph, false);
 
-       /*
-        * Also set the graph as being configured: it has no active sink
-        * anyway, so we don't need to call bt_graph_configure().
-        */
-       graph->config_state = BT_GRAPH_CONFIGURATION_STATE_CONFIGURED;
+       /* Also set the graph as being configured. */
+       graph_status = bt_graph_configure(graph);
+       if (graph_status != BT_GRAPH_STATUS_OK) {
+               BT_LIB_LOGW("Cannot configure graph after having added colander: "
+                       "%![graph-]+g, status=%s", graph,
+                       bt_graph_status_string(graph_status));
+               goto error;
+       }
        goto end;
 
 error:
This page took 0.02646 seconds and 4 git commands to generate.