lib: mark graph as faulty when adding a comp. or connecting ports fails
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 19 Mar 2019 18:51:38 +0000 (14:51 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 3 May 2019 22:19:38 +0000 (18:19 -0400)
commit9a84962bdef44af6069fc23e01cd55691fb268cb
tree013fa432949757e4a96e6918a017ca462e1324e2
parent12c700bef5ecb8a1b124c996c1147f7ae38d955c
lib: mark graph as faulty when adding a comp. or connecting ports fails

This patch makes the graph's state become
`BT_GRAPH_CONFIGURATION_STATE_FAULTY` when there's a configuration
error, that is, when one of the bt_graph_add_*_component*() functions or
the bt_graph_connect_ports() fail.

When a graph is faulty, it becomes impossible to use it in any way,
either to continue configuring it or to run it.

This new state makes it invalid to do anything with a graph when it
failed one of its configuration steps, so that each step must succeed in
order to get a valid, useable, configured graph. This fixes the issue
where in bt_graph_connect_ports(), one of the "port connected" method
would succeed but the other would fail: in this scenario, the connection
ends immediately (disconnecting each port), but one component still
believes that its port was successfully connected (as there's no "port
disconnected" method, because we don't need it for anything else). With
this patch, the component's "port connected" is still called and
successful, but the component will never be used anyway, so there's less
danger for errors. bt_port_is_connected() will indeed return `BT_FALSE`
for this port in the component's finalization method, for example.

The alternative would be to add an optional component method to indicate
that a port which was just connected is in fact not connected because
the other component's "port connected" method failed. This is possible,
but what can a graph's user do with a failing bt_graph_connect_ports()
anyway? If the intention was to connect two ports, and this operation
fails, then there's probably no plan B: retrying the exact same port
connection would probably fail again.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
include/babeltrace/graph/graph-internal.h
lib/graph/graph.c
This page took 0.025979 seconds and 4 git commands to generate.