+static
+enum lttng_live_iterator_status lttng_live_iterator_close_stream(
+ struct lttng_live_msg_iter *lttng_live_msg_iter,
+ struct lttng_live_stream_iterator *stream_iter,
+ bt_message **curr_msg)
+{
+ enum lttng_live_iterator_status live_status =
+ LTTNG_LIVE_ITERATOR_STATUS_OK;
+ /*
+ * The viewer has hung up on us so we are closing the stream. The
+ * `bt_msg_iter` should simply realize that it needs to close the
+ * stream properly by emitting the necessary stream end message.
+ */
+ enum bt_msg_iter_status status =
+ bt_msg_iter_get_next_message(stream_iter->msg_iter,
+ lttng_live_msg_iter->self_msg_iter, curr_msg);
+
+ if (status == BT_MSG_ITER_STATUS_ERROR) {
+ live_status = LTTNG_LIVE_ITERATOR_STATUS_ERROR;
+ goto end;
+ }
+
+ BT_ASSERT(status == BT_MSG_ITER_STATUS_OK);
+
+end:
+ return live_status;
+}
+