Fix graph facilities handling in writer component class
authorJulien Desfossez <jdesfossez@efficios.com>
Mon, 27 Feb 2017 19:53:41 +0000 (14:53 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:39 +0000 (12:57 -0400)
Commit 43e5ad310e9ea54e86dd3444e23c2d3c69827bc9 missed a few details to
make it work properly.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
plugins/writer/writer.c
plugins/writer/writer.h

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;
 }
index 6c6fed35f89bf030db1846096b7d5fbeffd986ba..f5c0d10891cd903facd9070f91e025002876a937 100644 (file)
@@ -45,6 +45,7 @@ struct writer_component {
        GHashTable *stream_class_map;
        FILE *err;
        struct bt_notification_iterator *input_iterator;
+       bool processed_first_event;
 };
 
 BT_HIDDEN
This page took 0.026192 seconds and 4 git commands to generate.