Merge real index and cycles index into a single index
[babeltrace.git] / formats / lttng-live / lttng-live-functions.c
index b1bc28405f89ff006894ac84da393b97c26b5da7..375a05edeafd52b468a4f1b61709641eb7f99ec5 100644 (file)
@@ -230,11 +230,6 @@ int lttng_live_ctf_trace_assign(struct lttng_live_viewer_stream *stream,
                        (gpointer) ctf_trace_id);
        if (!trace) {
                trace = g_new0(struct lttng_live_ctf_trace, 1);
-               if (!trace) {
-                       ret = -1;
-                       fprintf(stderr, "[error] ctf_trace allocation\n");
-                       goto error;
-               }
                trace->ctf_trace_id = ctf_trace_id;
                trace->streams = g_ptr_array_new();
                g_hash_table_insert(stream->session->ctf_traces,
@@ -247,7 +242,6 @@ int lttng_live_ctf_trace_assign(struct lttng_live_viewer_stream *stream,
        stream->ctf_trace = trace;
        g_ptr_array_add(trace->streams, stream);
 
-error:
        return ret;
 }
 
@@ -343,11 +337,6 @@ int lttng_live_attach_session(struct lttng_live_ctx *ctx, uint64_t id)
                ctx->session->stream_count);
        ctx->session->streams = g_new0(struct lttng_live_viewer_stream,
                        ctx->session->stream_count);
-       if (!ctx->session->streams) {
-               ret = -1;
-               goto error;
-       }
-
        for (i = 0; i < be32toh(rp.streams_count); i++) {
                do {
                        ret_len = recv(ctx->control_sock, &stream, sizeof(stream), 0);
@@ -465,7 +454,13 @@ int get_data_packet(struct lttng_live_ctx *ctx,
                ret = ret_len;
                goto error;
        }
-       assert(ret_len == sizeof(rp));
+       if (ret_len != sizeof(rp)) {
+               fprintf(stderr, "[error] get_data_packet: expected %" PRId64
+                               ", received %" PRId64 "\n", ret_len,
+                               sizeof(rp));
+               ret = -1;
+               goto error;
+       }
 
        rp.flags = be32toh(rp.flags);
 
@@ -727,7 +722,7 @@ retry:
        case LTTNG_VIEWER_INDEX_INACTIVE:
                printf_verbose("get_next_index: inactive\n");
                memset(index, 0, sizeof(struct packet_index));
-               index->timestamp_end = be64toh(rp.timestamp_end);
+               index->ts_cycles.timestamp_end = be64toh(rp.timestamp_end);
                break;
        case LTTNG_VIEWER_INDEX_OK:
                printf_verbose("get_next_index: Ok, need metadata update : %u\n",
@@ -735,8 +730,8 @@ retry:
                index->offset = be64toh(rp.offset);
                index->packet_size = be64toh(rp.packet_size);
                index->content_size = be64toh(rp.content_size);
-               index->timestamp_begin = be64toh(rp.timestamp_begin);
-               index->timestamp_end = be64toh(rp.timestamp_end);
+               index->ts_cycles.timestamp_begin = be64toh(rp.timestamp_begin);
+               index->ts_cycles.timestamp_end = be64toh(rp.timestamp_end);
                index->events_discarded = be64toh(rp.events_discarded);
 
                if (rp.flags & LTTNG_VIEWER_FLAG_NEW_METADATA) {
@@ -808,13 +803,13 @@ retry:
        }
 
        if (packet_index.content_size == 0) {
-               file_stream->parent.cycles_timestamp = packet_index.timestamp_end;
+               file_stream->parent.cycles_timestamp = packet_index.ts_cycles.timestamp_end;
                file_stream->parent.real_timestamp = ctf_get_real_timestamp(
-                               &file_stream->parent, packet_index.timestamp_end);
+                               &file_stream->parent, packet_index.ts_cycles.timestamp_end);
        } else {
-               file_stream->parent.cycles_timestamp = packet_index.timestamp_begin;
+               file_stream->parent.cycles_timestamp = packet_index.ts_cycles.timestamp_begin;
                file_stream->parent.real_timestamp = ctf_get_real_timestamp(
-                               &file_stream->parent, packet_index.timestamp_begin);
+                               &file_stream->parent, packet_index.ts_cycles.timestamp_begin);
        }
 
        if (pos->packet_size == 0 || pos->offset == EOF) {
@@ -838,7 +833,8 @@ retry:
                        ", offset %" PRIu64 ", content_size %" PRIu64
                        ", timestamp_end : %" PRIu64 "\n",
                        packet_index.packet_size, packet_index.offset,
-                       packet_index.content_size, packet_index.timestamp_end);
+                       packet_index.content_size,
+                       packet_index.ts_cycles.timestamp_end);
 
        /* update trace_packet_header and stream_packet_context */
        if (pos->prot != PROT_WRITE && file_stream->parent.trace_packet_header) {
This page took 0.024314 seconds and 4 git commands to generate.