- vstream->index_read_fd = -1;
-
- ret = close(vstream->read_fd);
- if (ret < 0) {
- PERROR("close tracefile %d", vstream->read_fd);
+ if (vstream->stream_file.fd) {
+ stream_fd_put(vstream->stream_file.fd);
+ vstream->stream_file.fd = NULL;
+ }
+ vstream->index_file =
+ lttng_index_file_create_from_trace_chunk_read_only(
+ stream->trace_chunk, stream->path_name,
+ stream->channel_name,
+ stream->tracefile_size,
+ vstream->current_tracefile_id,
+ lttng_to_index_major(connection_major,
+ connection_minor),
+ lttng_to_index_minor(connection_major,
+ connection_minor));
+ if (!vstream->index_file) {
+ ret = -1;
+ goto end;
+ } else {
+ ret = 0;