Use abort() instead of a false assertion
[babeltrace.git] / plugins / ctf / fs-sink / writer.c
index 211a6a9c037c0657bdba27cd993b5bda15866cfe..18abc9e311ca175e088eb7f3bb9e01d064949c6e 100644 (file)
@@ -192,6 +192,11 @@ void writer_component_port_connected(
 {
        struct bt_private_connection *connection;
        struct writer_component *writer;
+       static const enum bt_notification_type notif_types[] = {
+               BT_NOTIFICATION_TYPE_PACKET_BEGIN,
+               BT_NOTIFICATION_TYPE_PACKET_END,
+               BT_NOTIFICATION_TYPE_SENTINEL,
+       };
 
        writer = bt_private_component_get_user_data(component);
        assert(writer);
@@ -200,7 +205,7 @@ void writer_component_port_connected(
        assert(connection);
        writer->input_iterator =
                bt_private_connection_create_notification_iterator(connection,
-                       NULL);
+                       notif_types);
 
        if (!writer->input_iterator) {
                writer->error = true;
@@ -217,40 +222,35 @@ enum bt_component_status writer_run(struct bt_private_component *component)
        struct bt_notification_iterator *it;
        struct writer_component *writer_component =
                bt_private_component_get_user_data(component);
-
-       it = writer_component->input_iterator;
-       assert(it);
+       enum bt_notification_iterator_status it_ret;
 
        if (unlikely(writer_component->error)) {
                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 = writer_component->input_iterator;
+       assert(it);
+       it_ret = bt_notification_iterator_next(it);
 
-       notification = bt_notification_iterator_get_notification(it);
-       if (!notification) {
+       switch (it_ret) {
+       case BT_NOTIFICATION_ITERATOR_STATUS_END:
+               ret = BT_COMPONENT_STATUS_END;
+               BT_PUT(writer_component->input_iterator);
+               goto end;
+       case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN:
+               ret = BT_COMPONENT_STATUS_AGAIN;
+               goto end;
+       case BT_NOTIFICATION_ITERATOR_STATUS_OK:
+               break;
+       default:
                ret = BT_COMPONENT_STATUS_ERROR;
                goto end;
        }
 
+       notification = bt_notification_iterator_get_notification(it);
+       assert(notification);
        ret = handle_notification(writer_component, notification);
-       writer_component->processed_first_event = true;
 end:
        bt_put(notification);
        return ret;
This page took 0.025166 seconds and 4 git commands to generate.