sink.utils.counter: 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)
Same as the previous patch, but for the counter component.

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

index 817d09945884b46954d7bd7faf6c3a1d4f6b9f1c..24cf37feec66d3ca5302201b4d917aa626978b21 100644 (file)
@@ -230,15 +230,15 @@ end:
 bt_component_class_sink_consume_method_status counter_consume(
                bt_self_component_sink *comp)
 {
-       bt_component_class_sink_consume_method_status status =
-               BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK;
+       bt_component_class_sink_consume_method_status status;
        struct counter *counter;
        bt_message_iterator_next_status next_status;
        uint64_t msg_count;
        bt_message_array_const msgs;
+       bt_self_component *self_comp =
+               bt_self_component_sink_as_self_component(comp);
 
-       counter = bt_self_component_get_data(
-                       bt_self_component_sink_as_self_component(comp));
+       counter = bt_self_component_get_data(self_comp);
        BT_ASSERT_DBG(counter);
 
        if (G_UNLIKELY(!counter->msg_iter)) {
@@ -250,10 +250,6 @@ bt_component_class_sink_consume_method_status counter_consume(
        /* Consume messages */
        next_status = bt_message_iterator_next(
                counter->msg_iter, &msgs, &msg_count);
-       if (next_status < 0) {
-               status = (int) next_status;
-               goto end;
-       }
 
        switch (next_status) {
        case BT_MESSAGE_ITERATOR_NEXT_STATUS_OK:
@@ -296,24 +292,22 @@ bt_component_class_sink_consume_method_status counter_consume(
                        bt_message_put_ref(msg);
                }
 
-               status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK;
+               try_print_count(counter, msg_count);
                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:
                try_print_last(counter);
-               status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_END;
-               goto end;
+               break;
+       case BT_MESSAGE_ITERATOR_NEXT_STATUS_ERROR:
        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;
        }
 
-       try_print_count(counter, msg_count);
+       status = (int) next_status;
 
 end:
        return status;
This page took 0.025209 seconds and 4 git commands to generate.