Component iterator points to first notification on creation
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 11 Dec 2016 08:49:34 +0000 (03:49 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 27 May 2017 18:09:08 +0000 (14:09 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
plugins/ctf/fs/fs.c
plugins/text/text.c
plugins/text/text.h

index 9ddff2a3abf24705c91652ebf785cd82b3721297..3a60b0d5e40d4dd632658c73fed9b30f7290bcb1 100644 (file)
 BT_HIDDEN
 bool ctf_fs_debug;
 
+static
+enum bt_notification_iterator_status ctf_fs_iterator_next(
+               struct bt_notification_iterator *iterator);
+
 static
 struct bt_notification *ctf_fs_iterator_get(
                struct bt_notification_iterator *iterator)
@@ -56,6 +60,10 @@ struct bt_notification *ctf_fs_iterator_get(
        struct ctf_fs_iterator *ctf_it =
                        bt_notification_iterator_get_private_data(iterator);
 
+       if (!ctf_it->current_notification) {
+               (void) ctf_fs_iterator_next(iterator);
+       }
+
        return bt_get(ctf_it->current_notification);
 }
 
@@ -633,6 +641,7 @@ enum bt_component_status ctf_fs_iterator_init(struct bt_component *source,
        if (ret) {
                goto error;
        }
+
 end:
        return ret;
 error:
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);
index 5697e2ee5e974c3c7a98d56dffcb4bd3acd09325..ef80ce3e4777e635b9fca42380ac644a896b9d05 100644 (file)
@@ -69,7 +69,7 @@ struct text_options {
 struct text_component {
        struct text_options options;
        FILE *out, *err;
-       bool processed_first_event;
+       bool processed_first_event; /* Should be per-iterator. */
        int depth;      /* nesting, used for tabulation alignment. */
        bool start_line;
        GString *string;
This page took 0.029355 seconds and 4 git commands to generate.