Fix graph facilities handling in writer component class
[babeltrace.git] / plugins / writer / writer.c
index 48c3152a7987d53c0e848169a44db9b9d4fa54c9..f0aa8badf371603df8d30e225eacb03bfcb36161 100644 (file)
@@ -97,6 +97,7 @@ struct writer_component *create_writer_component(void)
        writer_component->err = stderr;
        writer_component->trace_id = 0;
        writer_component->trace_name_base = g_string_new("trace");
+       writer_component->processed_first_event = false;
        if (!writer_component->trace_name_base) {
                g_free(writer_component);
                writer_component = NULL;
@@ -221,21 +222,32 @@ enum bt_component_status run(struct bt_private_component *component)
        it = writer_component->input_iterator;
        assert(it);
 
-       notification = bt_notification_iterator_get_notification(it);
-       if (!notification) {
-               ret = BT_COMPONENT_STATUS_ERROR;
-               goto end;
+       if (likely(writer_component->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;
+                               BT_PUT(writer_component->input_iterator);
+                               goto end;
+                       default:
+                               break;
+               }
        }
 
-       it_status = bt_notification_iterator_next(it);
-       if (it_status != BT_COMPONENT_STATUS_OK) {
+       notification = bt_notification_iterator_get_notification(it);
+       if (!notification) {
                ret = BT_COMPONENT_STATUS_ERROR;
                goto end;
        }
 
        ret = handle_notification(writer_component, notification);
+       writer_component->processed_first_event = true;
 end:
-       bt_put(it);
        bt_put(notification);
        return ret;
 }
This page took 0.025 seconds and 4 git commands to generate.