From: Mathieu Desnoyers Date: Thu, 12 Dec 2019 18:19:36 +0000 (-0500) Subject: relayd: viewer-stream: introduce viewer_stream_close_files and viewer_stream_sync_tra... X-Git-Tag: v2.12.0-rc1~120 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=3087b021f1319ad541ddeeda868c2180d05dcae5;p=lttng-tools.git relayd: viewer-stream: introduce viewer_stream_close_files and viewer_stream_sync_tracefile_array_tail 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 Change-Id: I5d2f72868625b00b207c75c202bc514768c35166 Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-relayd/viewer-stream.c b/src/bin/lttng-relayd/viewer-stream.c index 70654c797..42431a8fa 100644 --- a/src/bin/lttng-relayd/viewer-stream.c +++ b/src/bin/lttng-relayd/viewer-stream.c @@ -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. * diff --git a/src/bin/lttng-relayd/viewer-stream.h b/src/bin/lttng-relayd/viewer-stream.h index 18a3521d7..a3262e242 100644 --- a/src/bin/lttng-relayd/viewer-stream.h +++ b/src/bin/lttng-relayd/viewer-stream.h @@ -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 */