static void viewer_stream_destroy(struct relay_viewer_stream *vstream)
{
+ lttng_trace_chunk_put(vstream->stream_file.trace_chunk);
free(vstream->path_name);
free(vstream->channel_name);
free(vstream);
enum lttng_viewer_seek seek_t)
{
struct relay_viewer_stream *vstream = NULL;
- const bool acquired_reference = lttng_trace_chunk_get(trace_chunk);
ASSERT_LOCKED(stream->lock);
- if (!acquired_reference) {
- goto error;
- }
vstream = zmalloc(sizeof(*vstream));
if (!vstream) {
goto error;
}
+ if (trace_chunk) {
+ const bool acquired_reference = lttng_trace_chunk_get(
+ trace_chunk);
+
+ assert(acquired_reference);
+ }
+
vstream->stream_file.trace_chunk = trace_chunk;
- trace_chunk = NULL;
vstream->path_name = lttng_strndup(stream->path_name, LTTNG_VIEWER_PATH_MAX);
if (vstream->path_name == NULL) {
PERROR("relay viewer path_name alloc");
vstream);
}
+ vstream->last_seen_rotation_count = stream->completed_rotation_count;
+
/* Globally visible after the add unique. */
lttng_ht_node_init_u64(&vstream->stream_n, stream->stream_handle);
urcu_ref_init(&vstream->ref);
if (vstream) {
viewer_stream_destroy(vstream);
}
- if (trace_chunk && acquired_reference) {
- lttng_trace_chunk_put(trace_chunk);
- }
return NULL;
}
if (seq_tail == -1ULL) {
seq_tail = 0;
}
- vstream->index_sent_seqcount = seq_tail;
+
+ /*
+ * Move the index sent seqcount forward if it was lagging behind
+ * the new tail of the tracefile array. If the current
+ * index_sent_seqcount is already further than the tracefile
+ * array tail position, keep its current position.
+ */
+ vstream->index_sent_seqcount = seq_tail > vstream->index_sent_seqcount ?
+ seq_tail : vstream->index_sent_seqcount;
}
/*