diff --git a/include/babeltrace2/graph/graph.h b/include/babeltrace2/graph/graph.h index 9ef943d72..e4d53e6e6 100644 --- a/include/babeltrace2/graph/graph.h +++ b/include/babeltrace2/graph/graph.h @@ -191,7 +191,6 @@ typedef enum bt_graph_run_status { BT_GRAPH_RUN_STATUS_ERROR = __BT_FUNC_STATUS_ERROR, BT_GRAPH_RUN_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, BT_GRAPH_RUN_STATUS_AGAIN = __BT_FUNC_STATUS_AGAIN, - BT_GRAPH_RUN_STATUS_END = __BT_FUNC_STATUS_END, } bt_graph_run_status; extern bt_graph_run_status bt_graph_run(bt_graph *graph); diff --git a/src/bindings/python/bt2/bt2/graph.py b/src/bindings/python/bt2/bt2/graph.py index ef40014ba..a36c85d1b 100644 --- a/src/bindings/python/bt2/bt2/graph.py +++ b/src/bindings/python/bt2/bt2/graph.py @@ -189,14 +189,7 @@ def run_once(self): def run(self): status = native_bt.graph_run(self._ptr) - - try: - utils._handle_func_status(status, 'graph object stopped running') - except bt2.Stop: - # done - return - except Exception: - raise + utils._handle_func_status(status, 'graph object stopped running') def add_interrupter(self, interrupter): utils._check_type(interrupter, bt2_interrupter.Interrupter) diff --git a/src/cli/babeltrace2.c b/src/cli/babeltrace2.c index 150b08fc1..e721ea3b7 100644 --- a/src/cli/babeltrace2.c +++ b/src/cli/babeltrace2.c @@ -2536,7 +2536,7 @@ int cmd_run(struct bt_config *cfg) switch (run_status) { case BT_GRAPH_RUN_STATUS_OK: - break; + goto end; case BT_GRAPH_RUN_STATUS_AGAIN: if (bt_interrupter_is_set(the_interrupter)) { BT_CLI_LOGW_APPEND_CAUSE( @@ -2558,8 +2558,6 @@ int cmd_run(struct bt_config *cfg) } } break; - case BT_GRAPH_RUN_STATUS_END: - goto end; default: if (bt_interrupter_is_set(the_interrupter)) { BT_CLI_LOGW_APPEND_CAUSE( diff --git a/src/lib/graph/graph.c b/src/lib/graph/graph.c index 44a5e1b4d..ed66ba89e 100644 --- a/src/lib/graph/graph.c +++ b/src/lib/graph/graph.c @@ -773,8 +773,15 @@ enum bt_graph_run_status bt_graph_run(struct bt_graph *graph) } } while (status == BT_FUNC_STATUS_OK); - if (g_queue_is_empty(graph->sinks_to_consume)) { - status = BT_FUNC_STATUS_END; + if (status == BT_FUNC_STATUS_END) { + /* + * The last call to consume_no_check() returned + * `BT_FUNC_STATUS_END`, but bt_graph_run() has no + * `BT_GRAPH_RUN_STATUS_END` status: replace with + * `BT_GRAPH_RUN_STATUS_OK` (success: graph ran + * completely). + */ + status = BT_FUNC_STATUS_OK; } end: