graph: check if graph has at least one sink to return the NO_SINK status
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 4 Aug 2017 21:42:03 +0000 (17:42 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 11 Aug 2017 22:54:16 +0000 (18:54 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/babeltrace/graph/graph-internal.h
lib/graph/graph.c

index 1e8b1b79ab3407671b39848e4b1d4baa89f119be..677c65bd219edc5cf1b9779ac1a60e3b79ce955b 100644 (file)
@@ -59,6 +59,7 @@ struct bt_graph {
 
        bt_bool canceled;
        bt_bool in_remove_listener;
+       bt_bool has_sink;
 
        struct {
                GArray *port_added;
index 747a282601d5622543139a683b15e62572db9515..7b013d358b9d2d03223ea5cdf848aa2ca4153111 100644 (file)
@@ -419,6 +419,12 @@ enum bt_graph_status bt_graph_consume_no_check(struct bt_graph *graph)
 
        BT_LOGV("Making next sink consume: addr=%p", graph);
 
+       if (!graph->has_sink) {
+               BT_LOGW_STR("Graph has no sink component.");
+               status = BT_GRAPH_STATUS_NO_SINK;
+               goto end;
+       }
+
        if (g_queue_is_empty(graph->sinks_to_consume)) {
                BT_LOGV_STR("Graph's sink queue is empty: end of graph.");
                status = BT_GRAPH_STATUS_END;
@@ -539,6 +545,8 @@ 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);
 
@@ -967,6 +975,7 @@ enum bt_graph_status bt_graph_add_component_with_init_method_data(
         * sink queue to be consumed by bt_graph_consume().
         */
        if (bt_component_is_sink(component)) {
+               graph->has_sink = BT_TRUE;
                g_queue_push_tail(graph->sinks_to_consume, component);
        }
 
This page took 0.026774 seconds and 4 git commands to generate.