static
void unref_stream_class(struct bt_ctf_stream_class *writer_stream_class)
{
- BT_PUT(writer_stream_class);
- g_free(writer_stream_class);
+ bt_put(writer_stream_class);
}
static
void unref_stream(struct bt_ctf_stream_class *writer_stream)
{
- BT_PUT(writer_stream);
- g_free(writer_stream);
+ bt_put(writer_stream);
}
static
void unref_trace(struct bt_ctf_writer *writer)
{
- BT_PUT(writer);
- g_free(writer);
+ bt_put(writer);
}
static
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;
}
static
-enum bt_component_status writer_component_accept_port_connection(
+void writer_component_port_connected(
struct bt_private_component *component,
struct bt_private_port *self_port,
struct bt_port *other_port)
{
- enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
struct bt_private_connection *connection;
struct writer_component *writer;
bt_private_connection_create_notification_iterator(connection);
if (!writer->input_iterator) {
- ret = BT_COMPONENT_STATUS_ERROR;
+ writer->error = true;
}
+
bt_put(connection);
- return ret;
}
static
enum bt_component_status run(struct bt_private_component *component)
{
enum bt_component_status ret;
- enum bt_notification_iterator_status it_status;
struct bt_notification *notification = NULL;
struct bt_notification_iterator *it;
struct writer_component *writer_component =
it = writer_component->input_iterator;
assert(it);
- notification = bt_notification_iterator_get_notification(it);
- if (!notification) {
+ if (unlikely(writer_component->error)) {
ret = BT_COMPONENT_STATUS_ERROR;
goto end;
}
- it_status = bt_notification_iterator_next(it);
- if (it_status != BT_COMPONENT_STATUS_OK) {
+ 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;
+ }
+ }
+
+ 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;
}
ret = BT_COMPONENT_STATUS_INVALID;
goto error;
}
+ bt_put(value);
writer_component->base_path = g_string_new(path);
if (!writer_component) {
BT_PLUGIN_LICENSE("MIT");
BT_PLUGIN_SINK_COMPONENT_CLASS(writer, run);
BT_PLUGIN_SINK_COMPONENT_CLASS_INIT_METHOD(writer, writer_component_init);
-BT_PLUGIN_SINK_COMPONENT_CLASS_ACCEPT_PORT_CONNECTION_METHOD(writer,
- writer_component_accept_port_connection);
+BT_PLUGIN_SINK_COMPONENT_CLASS_PORT_CONNECTED_METHOD(writer,
+ writer_component_port_connected);
BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(writer, finalize_writer_component);
BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION(writer, "Formats CTF-IR to CTF.");