Component iterator points to first notification on creation
[babeltrace.git] / plugins / text / text.c
index 89fa59901d63cac78c253175822b8e155d253017..6781b1b66e20237907c7dcd616643ba557f6c415 100644 (file)
@@ -164,15 +164,21 @@ enum bt_component_status run(struct bt_component *component)
                goto end;
        }
 
-       if (!text->processed_first_event) {
-               ret = bt_notification_iterator_next(it);
-               if (ret != BT_COMPONENT_STATUS_OK) {
+       if (likely(text->processed_first_event)) {
+               enum bt_notification_iterator_status it_ret;
+
+               it_ret = bt_notification_iterator_next(it);
+               switch (it_ret) {
+               case BT_NOTIFICATION_ITERATOR_STATUS_ERROR:
+                       ret = BT_COMPONENT_STATUS_ERROR;
+                       goto end;
+               case BT_NOTIFICATION_ITERATOR_STATUS_END:
+                       ret = BT_COMPONENT_STATUS_END;
                        goto end;
+               default:
+                       break;
                }
-       } else {
-               text->processed_first_event = true;
        }
-
        notification = bt_notification_iterator_get_notification(it);
        if (!notification) {
                ret = BT_COMPONENT_STATUS_ERROR;
@@ -180,6 +186,7 @@ enum bt_component_status run(struct bt_component *component)
        }
 
        ret = handle_notification(text, notification);
+       text->processed_first_event = true;
 end:
        bt_put(it);
        bt_put(notification);
This page took 0.024913 seconds and 4 git commands to generate.