From 8654d3067604d63b6df17571cac79c4485d6496f Mon Sep 17 00:00:00 2001 From: Julien Desfossez Date: Mon, 27 Feb 2017 14:53:41 -0500 Subject: [PATCH] Fix graph facilities handling in writer component class MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Commit 43e5ad310e9ea54e86dd3444e23c2d3c69827bc9 missed a few details to make it work properly. Signed-off-by: Julien Desfossez Signed-off-by: Jérémie Galarneau --- plugins/writer/writer.c | 26 +++++++++++++++++++------- plugins/writer/writer.h | 1 + 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/plugins/writer/writer.c b/plugins/writer/writer.c index 48c3152a..f0aa8bad 100644 --- a/plugins/writer/writer.c +++ b/plugins/writer/writer.c @@ -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; } diff --git a/plugins/writer/writer.h b/plugins/writer/writer.h index 6c6fed35..f5c0d108 100644 --- a/plugins/writer/writer.h +++ b/plugins/writer/writer.h @@ -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 -- 2.34.1