sink.utils.dummy: append error cause when call to bt_message_iterator_next()` fails
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 5 Mar 2024 20:50:13 +0000 (15:50 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 26 Mar 2024 18:56:36 +0000 (14:56 -0400)
I'm looking at some error stacks for a graph involving a dummy
component, and I noticed that it did not produce an error cause when
failing to consume.  I think it would be nice if it did, to avoid having
a gap in the error stack.

Change-Id: I1b7af3218f9937a21d3dee7406a2b03e122671c6
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12007
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
src/plugins/utils/dummy/dummy.c

index a1294c3d64a788ee71e3682447d2547b9f0d48c6..330a68632924890647b3dff2f44acef3c555bf5a 100644 (file)
@@ -127,16 +127,16 @@ end:
 bt_component_class_sink_consume_method_status dummy_consume(
                bt_self_component_sink *component)
 {
-       bt_component_class_sink_consume_method_status status =
-               BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK;
+       bt_component_class_sink_consume_method_status status;
        bt_message_array_const msgs;
        uint64_t count;
        struct dummy *dummy;
        bt_message_iterator_next_status next_status;
        uint64_t i;
+       bt_self_component *self_comp =
+               bt_self_component_sink_as_self_component(component);
 
-       dummy = bt_self_component_get_data(
-               bt_self_component_sink_as_self_component(component));
+       dummy = bt_self_component_get_data(self_comp);
        BT_ASSERT_DBG(dummy);
 
        if (G_UNLIKELY(!dummy->msg_iter)) {
@@ -149,29 +149,23 @@ bt_component_class_sink_consume_method_status dummy_consume(
                dummy->msg_iter, &msgs, &count);
        switch (next_status) {
        case BT_MESSAGE_ITERATOR_NEXT_STATUS_OK:
-               status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK;
-
                for (i = 0; i < count; i++) {
                        bt_message_put_ref(msgs[i]);
                }
 
                break;
-       case BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN:
-               status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_AGAIN;
-               goto end;
-       case BT_MESSAGE_ITERATOR_NEXT_STATUS_END:
-               status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_END;
-               goto end;
        case BT_MESSAGE_ITERATOR_NEXT_STATUS_ERROR:
-               status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR;
-               goto end;
        case BT_MESSAGE_ITERATOR_NEXT_STATUS_MEMORY_ERROR:
-               status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_MEMORY_ERROR;
-               goto end;
+               BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_COMPONENT(
+                       self_comp,
+                       "Failed to get messages from upstream component");
+               break;
        default:
                break;
        }
 
+       status = (int) next_status;
+
 end:
        return status;
 }
This page took 0.025738 seconds and 4 git commands to generate.