From: Julien Desfossez Date: Mon, 27 Feb 2017 19:53:41 +0000 (-0500) Subject: Fix graph facilities handling in writer component class X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=8654d3067604d63b6df17571cac79c4485d6496f;p=deliverable%2Fbabeltrace.git Fix graph facilities handling in writer component class Commit 43e5ad310e9ea54e86dd3444e23c2d3c69827bc9 missed a few details to make it work properly. Signed-off-by: Julien Desfossez Signed-off-by: Jérémie Galarneau --- diff --git a/plugins/writer/writer.c b/plugins/writer/writer.c index 48c3152a7..f0aa8badf 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 6c6fed35f..f5c0d1089 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