{
int ret;
char fullpath[PATH_MAX];
- struct lttng_packet_index_file_hdr hdr;
+ struct ctf_packet_index_file_hdr hdr;
if (stream->tracefile_count > 0) {
ret = snprintf(fullpath, sizeof(fullpath), "%s/" DEFAULT_INDEX_DIR "/%s_%"
PERROR("Reading index header");
goto error;
}
- if (strncmp(hdr.magic, INDEX_MAGIC, sizeof(hdr.magic)) != 0) {
+ if (be32toh(hdr.magic) != CTF_INDEX_MAGIC) {
ERR("Invalid header magic");
ret = -1;
goto error;
}
- if (be32toh(hdr.index_major) != INDEX_MAJOR ||
- be32toh(hdr.index_minor) != INDEX_MINOR) {
+ if (be32toh(hdr.index_major) != CTF_INDEX_MAJOR ||
+ be32toh(hdr.index_minor) != CTF_INDEX_MINOR) {
ERR("Invalid header version");
ret = -1;
goto error;
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;
if (seek_last && viewer_stream->index_read_fd > 0) {
ret = lseek(viewer_stream->index_read_fd,
viewer_stream->total_index_received *
- sizeof(struct lttng_packet_index),
+ sizeof(struct ctf_packet_index),
SEEK_CUR);
if (ret < 0) {
goto error;
/*
* 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;
}
int ret;
struct lttng_viewer_get_next_index request_index;
struct lttng_viewer_index viewer_index;
- struct lttng_packet_index packet_index;
+ struct ctf_packet_index packet_index;
struct relay_viewer_stream *vstream;
struct relay_stream *rstream;
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",