STATE_EMIT_MSG_PACKET_END_MULTI,
STATE_EMIT_MSG_PACKET_END_SINGLE,
STATE_EMIT_QUEUED_MSG_PACKET_END,
+ STATE_CHECK_EMIT_MSG_STREAM_END,
STATE_EMIT_MSG_STREAM_END,
STATE_DONE,
};
*/
bool emit_stream_beginning_message;
+ /*
+ * True if we need to emit a stream end message at the end of the
+ * current stream. A live stream may never receive any data and thus
+ * never send a stream beginning message which removes the need to emit
+ * a stream end message.
+ */
+ bool emit_stream_end_message;
+
/* Database of current dynamic scopes */
struct {
bt_field *stream_packet_context;
return "EMIT_MSG_PACKET_END_SINGLE";
case STATE_EMIT_QUEUED_MSG_PACKET_END:
return "EMIT_QUEUED_MSG_PACKET_END";
+ case STATE_CHECK_EMIT_MSG_STREAM_END:
+ return "CHECK_EMIT_MSG_STREAM_END";
case STATE_EMIT_MSG_STREAM_END:
return "EMIT_MSG_STREAM_END";
case STATE_DONE:
medium_status = msg_it->medium.medops.switch_packet(msg_it->medium.data);
if (medium_status == CTF_MSG_ITER_MEDIUM_STATUS_EOF) {
/* No more packets. */
- msg_it->state = STATE_EMIT_MSG_STREAM_END;
+ msg_it->state = STATE_CHECK_EMIT_MSG_STREAM_END;
status = CTF_MSG_ITER_STATUS_OK;
goto end;
} else if (medium_status != CTF_MSG_ITER_MEDIUM_STATUS_OK) {
break;
case CTF_MSG_ITER_STATUS_EOF:
status = CTF_MSG_ITER_STATUS_OK;
- msg_it->state = STATE_EMIT_MSG_STREAM_END;
+ msg_it->state = STATE_CHECK_EMIT_MSG_STREAM_END;
goto end;
default:
goto end;
return CTF_MSG_ITER_STATUS_OK;
}
+static inline
+enum state check_emit_msg_stream_end(struct ctf_msg_iter *msg_it)
+{
+ enum state next_state;
+
+ if (msg_it->emit_stream_end_message) {
+ next_state = STATE_EMIT_MSG_STREAM_END;
+ } else {
+ next_state = STATE_DONE;
+ }
+
+ return next_state;
+}
+
static inline
enum ctf_msg_iter_status handle_state(struct ctf_msg_iter *msg_it)
{
case STATE_EMIT_QUEUED_MSG_PACKET_END:
msg_it->state = STATE_EMIT_MSG_PACKET_END_SINGLE;
break;
+ case STATE_CHECK_EMIT_MSG_STREAM_END:
+ msg_it->state = check_emit_msg_stream_end(msg_it);
+ break;
case STATE_EMIT_MSG_STREAM_END:
msg_it->state = STATE_DONE;
break;
msg_it->prev_packet_snapshots.beginning_clock = UINT64_C(-1);
msg_it->prev_packet_snapshots.end_clock = UINT64_C(-1);
msg_it->emit_stream_beginning_message = true;
+ msg_it->emit_stream_end_message = false;
}
static
/* create_msg_stream_beginning() logs errors */
*message = create_msg_stream_beginning(msg_it);
msg_it->emit_stream_beginning_message = false;
+ msg_it->emit_stream_end_message = true;
if (!*message) {
status = CTF_MSG_ITER_STATUS_ERROR;
case STATE_EMIT_MSG_STREAM_END:
/* create_msg_stream_end() logs errors */
*message = create_msg_stream_end(msg_it);
+ msg_it->emit_stream_end_message = false;
if (!*message) {
status = CTF_MSG_ITER_STATUS_ERROR;