lib: remove `BT_GRAPH_RUN_STATUS_END`
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 29 Oct 2019 15:29:12 +0000 (11:29 -0400)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 31 Oct 2019 14:25:57 +0000 (10:25 -0400)
This patch makes bt_graph_run() return `BT_GRAPH_RUN_STATUS_OK` when the
graph is done running instead of `BT_GRAPH_RUN_STATUS_END`, as one of
them is redundant here and keeping an OK status looks like the right
decision.

bt_graph_run_once() is different: it returns
`BT_GRAPH_RUN_ONCE_STATUS_OK` once it's done running a single time, and
eventually `BT_GRAPH_RUN_ONCE_STATUS_END` when all the sink components
are ended.

In bt2.Graph.run(), the special case for `bt2.Stop` is removed as
`status` is never `BT_GRAPH_RUN_STATUS_END`.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I9d642292083c3bce0b7be263242f5b23d3713735
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2281
CI-Build: Francis Deslauriers <francis.deslauriers@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
include/babeltrace2/graph/graph.h
src/bindings/python/bt2/bt2/graph.py
src/cli/babeltrace2.c
src/lib/graph/graph.c

index 9ef943d7255823b935fd828abaa2c8c45c62a545..e4d53e6e661816e12d7ce5fb2410ee49a6e1183c 100644 (file)
@@ -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);
index ef40014ba9262e58e678193e2b9355c59a92de27..a36c85d1b7176cb37626aa1976775a40ec8454b8 100644 (file)
@@ -189,14 +189,7 @@ class Graph(object._SharedObject):
 
     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)
index 150b08fc12f69c079e65f5677a08fb267ec7c0bc..e721ea3b739e1bce2c0733935d5bc0f8605d96ba 100644 (file)
@@ -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(
index 44a5e1b4d657d98de328859f0df095734ea42e6b..ed66ba89ef5c2c13d1629c6421aa16ef5db80fa5 100644 (file)
@@ -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:
This page took 0.027812 seconds and 4 git commands to generate.