relayd: viewer-stream: introduce viewer_stream_close_files and viewer_stream_sync_tra...
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 12 Dec 2019 18:19:36 +0000 (13:19 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 19 Dec 2019 23:44:16 +0000 (18:44 -0500)
Introduce the following viewer helpers for clear:

- viewer_stream_close_files: Allow closing currently open viewer files.

- viewer_stream_sync_tracefile_array_tail: Allow updating the current
  tracefile id and the index sent seqcount based on the current content
  of the tracefile array.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I5d2f72868625b00b207c75c202bc514768c35166
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-relayd/viewer-stream.c
src/bin/lttng-relayd/viewer-stream.h

index 70654c79710c19a17f9e3a30d3795156fbfed1f9..42431a8fa3588fc20a5745f80c0e54ecb5887545 100644 (file)
@@ -261,6 +261,31 @@ void viewer_stream_put(struct relay_viewer_stream *vstream)
        rcu_read_unlock();
 }
 
+void viewer_stream_close_files(struct relay_viewer_stream *vstream)
+{
+       if (vstream->index_file) {
+               lttng_index_file_put(vstream->index_file);
+               vstream->index_file = NULL;
+       }
+       if (vstream->stream_file.fd) {
+               stream_fd_put(vstream->stream_file.fd);
+               vstream->stream_file.fd = NULL;
+       }
+}
+
+void viewer_stream_sync_tracefile_array_tail(struct relay_viewer_stream *vstream)
+{
+       const struct relay_stream *stream = vstream->stream;
+       uint64_t seq_tail;
+
+       vstream->current_tracefile_id = tracefile_array_get_file_index_tail(stream->tfa);
+       seq_tail = tracefile_array_get_seq_tail(stream->tfa);
+       if (seq_tail == -1ULL) {
+               seq_tail = 0;
+       }
+       vstream->index_sent_seqcount = seq_tail;
+}
+
 /*
  * Rotate a stream to the next tracefile.
  *
index 18a3521d7c117e049915a0ad2f791786493c66c0..a3262e24241d51cd72bda1ee1453bd17e03a27bd 100644 (file)
@@ -91,5 +91,7 @@ int viewer_stream_rotate(struct relay_viewer_stream *vstream);
 bool viewer_stream_is_tracefile_seq_readable(struct relay_viewer_stream *vstream,
                uint64_t seq);
 void print_viewer_streams(void);
+void viewer_stream_close_files(struct relay_viewer_stream *vstream);
+void viewer_stream_sync_tracefile_array_tail(struct relay_viewer_stream *vstream);
 
 #endif /* _VIEWER_STREAM_H */
This page took 0.02761 seconds and 5 git commands to generate.