tap-driver.sh: flush stdout after each test result
[babeltrace.git] / plugins / ctf / lttng-live / lttng-live.c
index ef33c776c6a91e32664bdb4a4f3710cfdd68c839..24544a307ace6d2fcb273ef557480020a7a342c2 100644 (file)
 #include <inttypes.h>
 #include <unistd.h>
 
-#include <babeltrace/assert-internal.h>
-#include <babeltrace/babeltrace.h>
-#include <babeltrace/compiler-internal.h>
-#include <babeltrace/types.h>
+#include <babeltrace2/assert-internal.h>
+#include <babeltrace2/babeltrace.h>
+#include <babeltrace2/compiler-internal.h>
+#include <babeltrace2/types.h>
 #include <plugins-common.h>
 
 #include "data-stream.h"
@@ -615,7 +615,6 @@ int live_get_msg_ts_ns(struct lttng_live_stream_iterator *stream_iter,
        const bt_clock_class *clock_class = NULL;
        const bt_clock_snapshot *clock_snapshot = NULL;
        int ret = 0;
-       bt_clock_snapshot_state cs_state = BT_CLOCK_SNAPSHOT_STATE_KNOWN;
        bt_message_stream_activity_clock_snapshot_state sa_cs_state;
 
        BT_ASSERT(msg);
@@ -632,8 +631,8 @@ int live_get_msg_ts_ns(struct lttng_live_stream_iterator *stream_iter,
                                msg);
                BT_ASSERT(clock_class);
 
-               cs_state = bt_message_event_borrow_default_clock_snapshot_const(
-                       msg, &clock_snapshot);
+               clock_snapshot = bt_message_event_borrow_default_clock_snapshot_const(
+                       msg);
                break;
        case BT_MESSAGE_TYPE_PACKET_BEGINNING:
                clock_class =
@@ -641,8 +640,8 @@ int live_get_msg_ts_ns(struct lttng_live_stream_iterator *stream_iter,
                        msg);
                BT_ASSERT(clock_class);
 
-               cs_state = bt_message_packet_beginning_borrow_default_clock_snapshot_const(
-                       msg, &clock_snapshot);
+               clock_snapshot = bt_message_packet_beginning_borrow_default_clock_snapshot_const(
+                       msg);
                break;
        case BT_MESSAGE_TYPE_PACKET_END:
                clock_class =
@@ -650,8 +649,8 @@ int live_get_msg_ts_ns(struct lttng_live_stream_iterator *stream_iter,
                        msg);
                BT_ASSERT(clock_class);
 
-               cs_state = bt_message_packet_end_borrow_default_clock_snapshot_const(
-                       msg, &clock_snapshot);
+               clock_snapshot = bt_message_packet_end_borrow_default_clock_snapshot_const(
+                       msg);
                break;
        case BT_MESSAGE_TYPE_DISCARDED_EVENTS:
                clock_class =
@@ -659,8 +658,8 @@ int live_get_msg_ts_ns(struct lttng_live_stream_iterator *stream_iter,
                        msg);
                BT_ASSERT(clock_class);
 
-               cs_state = bt_message_discarded_events_borrow_default_beginning_clock_snapshot_const(
-                       msg, &clock_snapshot);
+               clock_snapshot = bt_message_discarded_events_borrow_beginning_default_clock_snapshot_const(
+                       msg);
                break;
        case BT_MESSAGE_TYPE_DISCARDED_PACKETS:
                clock_class =
@@ -668,8 +667,8 @@ int live_get_msg_ts_ns(struct lttng_live_stream_iterator *stream_iter,
                        msg);
                BT_ASSERT(clock_class);
 
-               cs_state = bt_message_discarded_packets_borrow_default_beginning_clock_snapshot_const(
-                       msg, &clock_snapshot);
+               clock_snapshot = bt_message_discarded_packets_borrow_beginning_default_clock_snapshot_const(
+                       msg);
                break;
        case BT_MESSAGE_TYPE_STREAM_ACTIVITY_BEGINNING:
                clock_class =
@@ -698,9 +697,9 @@ int live_get_msg_ts_ns(struct lttng_live_stream_iterator *stream_iter,
 
                break;
        case BT_MESSAGE_TYPE_MESSAGE_ITERATOR_INACTIVITY:
-               cs_state =
+               clock_snapshot =
                        bt_message_message_iterator_inactivity_borrow_default_clock_snapshot_const(
-                               msg, &clock_snapshot);
+                               msg);
                break;
        default:
                /* All the other messages have a higher priority */
@@ -709,12 +708,6 @@ int live_get_msg_ts_ns(struct lttng_live_stream_iterator *stream_iter,
                goto end;
        }
 
-       if (cs_state != BT_CLOCK_SNAPSHOT_STATE_KNOWN) {
-               BT_LOGE_STR("Unsupported unknown clock snapshot.");
-               ret = -1;
-               goto end;
-       }
-
        clock_class = bt_clock_snapshot_borrow_clock_class_const(clock_snapshot);
        BT_ASSERT(clock_class);
 
@@ -1471,6 +1464,9 @@ end:
 static
 void lttng_live_component_destroy_data(struct lttng_live_component *lttng_live)
 {
+       if (!lttng_live) {
+               return;
+       }
        if (lttng_live->params.url) {
                g_string_free(lttng_live->params.url, TRUE);
        }
@@ -1576,25 +1572,30 @@ bt_self_component_status lttng_live_component_init(
        lttng_live = lttng_live_component_create(params);
        if (!lttng_live) {
                ret = BT_SELF_COMPONENT_STATUS_NOMEM;
-               goto end;
+               goto error;
        }
        lttng_live->self_comp = self_comp;
 
        if (lttng_live_graph_is_canceled(lttng_live)) {
-               goto end;
+               ret = BT_SELF_COMPONENT_STATUS_END;
+               goto error;
        }
 
        ret = bt_self_component_source_add_output_port(
                                lttng_live->self_comp, "out",
                                NULL, NULL);
        if (ret != BT_SELF_COMPONENT_STATUS_OK) {
-               goto end;
+               goto error;
        }
 
        bt_self_component_set_data(
                        bt_self_component_source_as_self_component(self_comp),
                        lttng_live);
+       goto end;
 
+error:
+       lttng_live_component_destroy_data(lttng_live);
+       lttng_live = NULL;
 end:
        return ret;
 }
This page took 0.025837 seconds and 4 git commands to generate.