Backport: relayd: replace lttng_index_file with relay_index_file
[lttng-tools.git] / src / bin / lttng-relayd / viewer-stream.c
index 8a3b09a92060ef25e9f9f8f50b2d36d15c2de159..2a580ca53f207840358970c0084c9894b7500cb9 100644 (file)
 
 #define _LGPL_SOURCE
 #include <common/common.h>
-#include <common/index/index.h>
 #include <common/compat/string.h>
 
 #include "lttng-relayd.h"
 #include "viewer-stream.h"
+#include "index-file.h"
 
 static void viewer_stream_destroy(struct relay_viewer_stream *vstream)
 {
@@ -118,7 +118,7 @@ struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream,
        if (stream->index_received_seqcount == 0) {
                vstream->index_file = NULL;
        } else {
-               vstream->index_file = lttng_index_file_open(vstream->path_name,
+               vstream->index_file = relay_index_file_open(vstream->path_name,
                                vstream->channel_name,
                                stream->tracefile_count,
                                vstream->current_tracefile_id);
@@ -128,10 +128,10 @@ struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream,
        }
 
        if (seek_t == LTTNG_VIEWER_SEEK_LAST && vstream->index_file) {
-               off_t lseek_ret;
+               int ret;
 
-               lseek_ret = lseek(vstream->index_file->fd, 0, SEEK_END);
-               if (lseek_ret < 0) {
+               ret = relay_index_file_seek_end(vstream->index_file);
+               if (ret < 0) {
                        goto error_unlock;
                }
        }
@@ -143,10 +143,9 @@ struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream,
 
        /* Globally visible after the add unique. */
        lttng_ht_node_init_u64(&vstream->stream_n, stream->stream_handle);
-       lttng_ht_add_unique_u64(viewer_streams_ht, &vstream->stream_n);
-
        pthread_mutex_init(&vstream->reflock, NULL);
        urcu_ref_init(&vstream->ref);
+       lttng_ht_add_unique_u64(viewer_streams_ht, &vstream->stream_n);
 
        return vstream;
 
@@ -185,7 +184,7 @@ static void viewer_stream_release(struct urcu_ref *ref)
                vstream->stream_fd = NULL;
        }
        if (vstream->index_file) {
-               lttng_index_file_put(vstream->index_file);
+               relay_index_file_put(vstream->index_file);
                vstream->index_file = NULL;
        }
        if (vstream->stream) {
@@ -298,7 +297,7 @@ int viewer_stream_rotate(struct relay_viewer_stream *vstream)
        }
 
        if (vstream->index_file) {
-               lttng_index_file_put(vstream->index_file);
+               relay_index_file_put(vstream->index_file);
                vstream->index_file = NULL;
        }
        if (vstream->stream_fd) {
@@ -306,7 +305,7 @@ int viewer_stream_rotate(struct relay_viewer_stream *vstream)
                vstream->stream_fd = NULL;
        }
 
-       vstream->index_file = lttng_index_file_open(vstream->path_name,
+       vstream->index_file = relay_index_file_open(vstream->path_name,
                        vstream->channel_name,
                        stream->tracefile_count,
                        vstream->current_tracefile_id);
This page took 0.026742 seconds and 5 git commands to generate.