- # As of this version, all the tracing session's stream infos are
- # always given to the viewer when sending the "attach to tracing
- # session" reply, so there's nothing new here. Return the `HUP`
- # status as, if we're handling this command, the viewer consumed
- # all the existing data streams.
- status = _LttngLiveViewerGetNewStreamInfosReply.Status.HUP
- return _LttngLiveViewerGetNewStreamInfosReply(status, [])
+ # Mark stream infos transmitted as part of the reply as
+ # announced.
+ for si in newly_announced_stream_infos:
+ if si.is_metadata:
+ self._get_metadata_stream_state(si.id).mark_as_announced()
+ else:
+ self._get_data_stream_state(si.id).mark_as_announced()
+
+ status = _LttngLiveViewerGetNewStreamInfosReply.Status.OK
+
+ if len(newly_announced_stream_infos) == 0:
+ # If all streams have been transmitted and no new traces are
+ # scheduled for creation, hang up to signal that the tracing
+ # session is "done".
+ status = (
+ _LttngLiveViewerGetNewStreamInfosReply.Status.HUP
+ if self._all_streams_finished()
+ else _LttngLiveViewerGetNewStreamInfosReply.Status.NO_NEW
+ )
+
+ return _LttngLiveViewerGetNewStreamInfosReply(
+ status, newly_announced_stream_infos
+ )