bt_port_output_message_iterator_create(): check that graph has no sinks
[babeltrace.git] / lib / graph / iterator.c
index 834a0b76f70818df85d8be0d8123abdd48d1c708..11f17dcdea31d1e2b7371205ef362f39ec1f6fd4 100644 (file)
@@ -750,6 +750,8 @@ bt_port_output_message_iterator_create(struct bt_graph *graph,
                (void *) graph,
                "Output port is not part of graph: %![graph-]+g, %![port-]+p",
                graph, output_port);
+       BT_ASSERT_PRE(!graph->has_sink,
+               "Graph already has a sink component: %![graph-]+g");
 
        /* Create message iterator */
        BT_LIB_LOGD("Creating message iterator on output port: "
@@ -975,7 +977,7 @@ bt_self_component_port_input_message_iterator_seek_beginning(
                status == BT_MESSAGE_ITERATOR_STATUS_NOMEM ||
                status == BT_MESSAGE_ITERATOR_STATUS_AGAIN,
                "Unexpected status: %![iter-]+i, status=%s",
-               iterator, bt_self_message_iterator_status_string(status));
+               iterator, bt_common_self_message_iterator_status_string(status));
        set_iterator_state_after_seeking(iterator, status);
        return status;
 }
@@ -1206,7 +1208,7 @@ enum bt_message_iterator_status find_message_ge_ns_from_origin(
 
        BT_ASSERT(iterator->methods.next);
 
-       while (true) {
+       while (!got_first) {
                /*
                 * Call the user's "next" method to get the next
                 * messages and status.
@@ -1253,7 +1255,7 @@ enum bt_message_iterator_status find_message_ge_ns_from_origin(
                        status = auto_seek_handle_message(iterator,
                                ns_from_origin, messages[i], &got_first);
                        if (status == BT_MESSAGE_ITERATOR_STATUS_OK) {
-                               /* Message was either put or moved */
+                               /* Message was either pushed or moved */
                                messages[i] = NULL;
                        } else {
                                goto end;
@@ -1359,7 +1361,7 @@ bt_self_component_port_input_message_iterator_seek_ns_from_origin(
                        status == BT_MESSAGE_ITERATOR_STATUS_AGAIN,
                        "Unexpected status: %![iter-]+i, status=%s",
                        iterator,
-                       bt_self_message_iterator_status_string(status));
+                       bt_common_self_message_iterator_status_string(status));
        } else {
                /* Start automatic seeking: seek beginning first */
                BT_ASSERT(iterator->methods.can_seek_beginning(iterator));
@@ -1375,7 +1377,7 @@ bt_self_component_port_input_message_iterator_seek_ns_from_origin(
                        status == BT_MESSAGE_ITERATOR_STATUS_AGAIN,
                        "Unexpected status: %![iter-]+i, status=%s",
                        iterator,
-                       bt_self_message_iterator_status_string(status));
+                       bt_common_self_message_iterator_status_string(status));
                switch (status) {
                case BT_MESSAGE_ITERATOR_STATUS_OK:
                        break;
This page took 0.02419 seconds and 4 git commands to generate.