- ret = make_viewer_streams(session, LTTNG_VIEWER_SEEK_LAST, &nb_total, &nb_unsent,
+ if (!session->current_trace_chunk) {
+ /*
+ * Means the session is being destroyed. React the same way
+ * as if it could not be found at all.
+ */
+ DBG("Relay session %" PRIu64 " has no current trace chunk, replying LTTNG_VIEWER_NEW_STREAMS_ERR",
+ session_id);
+ response.status = htobe32(LTTNG_VIEWER_NEW_STREAMS_ERR);
+ goto send_reply_unlock;
+ }
+
+ if (!conn->viewer_session->current_trace_chunk &&
+ session->current_trace_chunk) {
+ ret = viewer_session_set_trace_chunk(conn->viewer_session,
+ session->current_trace_chunk);
+ if (ret) {
+ goto error_unlock_session;
+ }
+ }
+ ret = make_viewer_streams(session,
+ conn->viewer_session->current_trace_chunk,
+ LTTNG_VIEWER_SEEK_LAST, &nb_total, &nb_unsent,