static
enum ctf_msg_iter_status switch_packet_state(struct ctf_msg_iter *msg_it)
{
- enum ctf_msg_iter_status status = CTF_MSG_ITER_STATUS_OK;
+ enum ctf_msg_iter_status status;
bt_self_component *self_comp = msg_it->self_comp;
/*
release_all_dscopes(msg_it);
msg_it->cur_dscope_field = NULL;
+ if (msg_it->medium.medops.switch_packet) {
+ enum ctf_msg_iter_medium_status medium_status;
+
+ 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_CHECK_EMIT_MSG_STREAM_END;
+ status = CTF_MSG_ITER_STATUS_OK;
+ goto end;
+ } else if (medium_status != CTF_MSG_ITER_MEDIUM_STATUS_OK) {
+ status = (int) medium_status;
+ goto end;
+ }
+
+ /*
+ * After the packet switch, the medium might want to give us a
+ * different buffer for the new packet.
+ */
+ status = request_medium_bytes(msg_it);
+ if (status != CTF_MSG_ITER_STATUS_OK) {
+ goto end;
+ }
+ }
+
/*
* Adjust current buffer so that addr points to the beginning of the new
* packet.
msg_it->snapshots.end_clock = UINT64_C(-1);
msg_it->state = STATE_DSCOPE_TRACE_PACKET_HEADER_BEGIN;
+ status = CTF_MSG_ITER_STATUS_OK;
end:
return status;
}
BT_ASSERT(tc);
BT_ASSERT(medops.request_bytes);
BT_ASSERT(medops.borrow_stream);
+ BT_ASSERT(max_request_sz > 0);
+
BT_COMP_LOG_CUR_LVL(BT_LOG_DEBUG, log_level, self_comp,
"Creating CTF plugin message iterator: "
"trace-addr=%p, max-request-size=%zu, "
return status;
}
-BT_HIDDEN
-void ctf_msg_iter_set_medops_data(struct ctf_msg_iter *msg_it,
- void *medops_data)
-{
- BT_ASSERT(msg_it);
- msg_it->medium.data = medops_data;
-}
-
BT_HIDDEN
enum ctf_msg_iter_status ctf_msg_iter_seek(struct ctf_msg_iter *msg_it,
off_t offset)
BT_ASSERT(msg_it);
BT_ASSERT(offset >= 0);
-
- if (!msg_it->medium.medops.seek) {
- status = CTF_MSG_ITER_STATUS_UNSUPPORTED;
- BT_COMP_LOGD("Aborting seek as the iterator's underlying media does not implement seek support.");
- goto end;
- }
+ BT_ASSERT(msg_it->medium.medops.seek);
medium_status = msg_it->medium.medops.seek(offset, msg_it->medium.data);
if (medium_status != CTF_MSG_ITER_MEDIUM_STATUS_OK) {