LTTNG_VIEWER_NAME_MAX);
viewer_stream->tracefile_count = stream->tracefile_count;
viewer_stream->metadata_flag = stream->metadata_flag;
+ viewer_stream->tracefile_count_last = -1ULL;
if (seek_last) {
viewer_stream->tracefile_count_current =
stream->tracefile_count_current;
/*
* Rotate a stream to the next tracefile.
*
- * Returns 0 on success, a negative value on error.
+ * Returns 0 on success, 1 on EOF, a negative value on error.
*/
static
int rotate_viewer_stream(struct relay_viewer_stream *viewer_stream,
tracefile_id = (viewer_stream->tracefile_count_current + 1) %
viewer_stream->tracefile_count;
+ /*
+ * Detect the last tracefile to open.
+ */
+ if (viewer_stream->tracefile_count_last != -1ULL &&
+ viewer_stream->tracefile_count_last ==
+ viewer_stream->tracefile_count_current) {
+ ret = 1;
+ goto end;
+ }
if (stream) {
pthread_mutex_lock(&stream->viewer_stream_rotation_lock);
ret = 0;
+end:
error:
return ret;
}
ret = rotate_viewer_stream(vstream, rstream);
if (ret < 0) {
goto end_unlock;
+ } else if (ret == 1) {
+ viewer_index.status = htobe32(VIEWER_INDEX_HUP);
+ goto send_reply;
}
}
pthread_mutex_lock(&rstream->viewer_stream_rotation_lock);
ret = rotate_viewer_stream(vstream, rstream);
if (ret < 0) {
goto end_unlock;
+ } else if (ret == 1) {
+ viewer_index.status = htobe32(VIEWER_INDEX_HUP);
+ goto send_reply;
}
goto send_reply;
}
ret = rotate_viewer_stream(vstream, rstream);
if (ret < 0) {
goto end_unlock;
+ } else if (ret == 1) {
+ viewer_index.status = htobe32(VIEWER_INDEX_HUP);
+ goto send_reply;
}
} else {
PERROR("Relay reading index file %d",
uint64_t total_index_received;
uint64_t tracefile_count;
uint64_t tracefile_count_current;
+ /* Stop after reading this tracefile. */
+ uint64_t tracefile_count_last;
struct lttng_ht_node_u64 stream_n;
struct rcu_head rcu_node;
struct ctf_trace *ctf_trace;
*/
pthread_mutex_lock(&stream->viewer_stream_rotation_lock);
vstream->total_index_received = stream->total_index_received;
+ vstream->tracefile_count_last = stream->tracefile_count_current;
vstream->close_write_flag = 1;
pthread_mutex_unlock(&stream->viewer_stream_rotation_lock);
}