+ if (lttng_trace_chunk_get_id(
+ conn->viewer_session->current_trace_chunk,
+ &vchunk_id) != LTTNG_TRACE_CHUNK_STATUS_OK) {
+ viewer_index.status = htobe32(LTTNG_VIEWER_INDEX_ERR);
+ goto send_reply;
+ }
+
+ if (rchunk_id != vchunk_id) {
+ DBG("Relay and viewer chunk ids differ: "
+ "rchunk_id %" PRIu64 " vchunk_id %" PRIu64,
+ rchunk_id, vchunk_id);
+
+ lttng_trace_chunk_put(
+ conn->viewer_session->current_trace_chunk);
+ conn->viewer_session->current_trace_chunk = NULL;
+ ret = viewer_session_set_trace_chunk_copy(
+ conn->viewer_session,
+ rstream->trace_chunk);
+ if (ret) {
+ viewer_index.status =
+ htobe32(LTTNG_VIEWER_INDEX_ERR);
+ goto send_reply;
+ }
+ }
+ }
+ if (conn->viewer_session->current_trace_chunk !=
+ vstream->stream_file.trace_chunk) {
+ bool acquired_reference;
+
+ DBG("Viewer session and viewer stream chunk differ: "
+ "vsession chunk %p vstream chunk %p",
+ conn->viewer_session->current_trace_chunk,
+ vstream->stream_file.trace_chunk);
+ lttng_trace_chunk_put(vstream->stream_file.trace_chunk);
+ acquired_reference = lttng_trace_chunk_get(conn->viewer_session->current_trace_chunk);
+ assert(acquired_reference);
+ vstream->stream_file.trace_chunk =
+ conn->viewer_session->current_trace_chunk;
+ viewer_stream_sync_tracefile_array_tail(vstream);
+ viewer_stream_close_files(vstream);