Fix: Report errors occuring in lttng_live_read
[babeltrace.git] / formats / lttng-live / lttng-live-comm.c
index 5a7d067e4cd55127c539b91b5bc169cebd8d772e..960c2240129cba5115223816b2a09f1578c5dd95 100644 (file)
@@ -631,8 +631,7 @@ retry:
 
        memset(&rq, 0, sizeof(rq));
        rq.stream_id = htobe64(stream->id);
-       /* Already in big endian. */
-       rq.offset = offset;
+       rq.offset = htobe64(offset);
        rq.len = htobe32(len);
 
        ret_len = lttng_live_send(ctx->control_sock, &cmd, sizeof(cmd));
@@ -1110,7 +1109,7 @@ retry:
        printf_verbose("get_data_packet for stream %" PRIu64 "\n",
                        viewer_stream->id);
        ret = get_data_packet(session->ctx, pos, viewer_stream,
-                       be64toh(cur_index->offset),
+                       cur_index->offset,
                        cur_index->packet_size / CHAR_BIT);
        if (ret == -2) {
                goto retry;
@@ -1430,9 +1429,10 @@ error:
        return -1;
 }
 
-void lttng_live_read(struct lttng_live_ctx *ctx)
+int lttng_live_read(struct lttng_live_ctx *ctx)
 {
-       int ret, i;
+       int ret = -1;
+       int i;
        struct bt_ctf_iter *iter;
        const struct bt_ctf_event *event;
        struct bt_iter_pos begin_pos;
@@ -1490,12 +1490,14 @@ void lttng_live_read(struct lttng_live_ctx *ctx)
                int flags;
 
                if (lttng_live_should_quit()) {
+                       ret = 0;
                        goto end_free;
                }
 
                while (!ctx->session->stream_count) {
                        if (lttng_live_should_quit()
                                        || ctx->session_ids->len == 0) {
+                               ret = 0;
                                goto end_free;
                        }
                        ret = ask_new_streams(ctx);
@@ -1518,6 +1520,7 @@ void lttng_live_read(struct lttng_live_ctx *ctx)
                }
                for (;;) {
                        if (lttng_live_should_quit()) {
+                               ret = 0;
                                goto end_free;
                        }
                        event = bt_ctf_iter_read_event_flags(iter, &flags);
@@ -1548,5 +1551,5 @@ void lttng_live_read(struct lttng_live_ctx *ctx)
 end_free:
        bt_context_put(ctx->bt_ctx);
 end:
-       return;
+       return ret;
 }
This page took 0.025597 seconds and 4 git commands to generate.