sync lttng and babeltrace last headers for live
[lttngtop.git] / src / network-live.c
index a0113f5efd3995126cfeb242468c220e714b7b49..46a5b4d2d0c317cd80de5be78c527b24c7871452 100644 (file)
@@ -35,7 +35,7 @@
 #include <sys/mman.h>
 
 #include "lttng-viewer.h"
-#include "lttng-index.h"
+#include "ctf-index.h"
 #include "network-live.h"
 
 #include <babeltrace/babeltrace.h>
@@ -220,28 +220,8 @@ error:
        return ret;
 }
 
-int write_index_header(int fd)
-{
-       struct lttng_packet_index_file_hdr hdr;
-       int ret;
-
-       memcpy(hdr.magic, INDEX_MAGIC, sizeof(hdr.magic));
-       hdr.index_major = htobe32(INDEX_MAJOR);
-       hdr.index_minor = htobe32(INDEX_MINOR);
-
-       do {
-               ret = write(fd, &hdr, sizeof(hdr));
-       } while (ret < 0 && errno == EINTR);
-       if (ret < 0) {
-               perror("write index header");
-               goto error;
-       }
-
-error:
-       return ret;
-}
-
-int attach_session(int id)
+static
+int attach_session(int id, int begin)
 {
        struct lttng_viewer_cmd cmd;
        struct lttng_viewer_attach_session_request rq;
@@ -254,8 +234,11 @@ int attach_session(int id)
        cmd.cmd_version = 0;
 
        rq.session_id = htobe64(id);
-       //rq.seek = htobe32(VIEWER_SEEK_BEGINNING);
-       rq.seek = htobe32(VIEWER_SEEK_LAST);
+       if (begin) {
+               rq.seek = htobe32(VIEWER_SEEK_BEGINNING);
+       } else {
+               rq.seek = htobe32(VIEWER_SEEK_LAST);
+       }
 
        do {
                ret = send(control_sock, &cmd, sizeof(cmd), 0);
@@ -671,6 +654,11 @@ void ctf_live_packet_seek(struct bt_stream_pos *stream_pos, size_t index,
        pos->content_size = packet_index.content_size;
        pos->mmap_base_offset = 0;
        pos->offset = 0;
+       if (packet_index.offset == EOF) {
+               pos->offset = EOF;
+       } else {
+               pos->offset = 0;
+       }
 
        file_stream->parent.cycles_timestamp = packet_index.timestamp_end;
        file_stream->parent.real_timestamp = ctf_get_real_timestamp(
@@ -801,7 +789,7 @@ end:
        return ret;
 }
 
-int setup_network_live(char *hostname)
+int setup_network_live(char *hostname, int begin)
 {
        int ret;
        int session_id;
@@ -837,7 +825,7 @@ int setup_network_live(char *hostname)
 
        do {
                fprintf(stderr, "* Attach session %d\n", ret);
-               ret = attach_session(session_id);
+               ret = attach_session(session_id, begin);
                if (ret < 0) {
                        goto error;
                }
This page took 0.023263 seconds and 4 git commands to generate.