- int ret;
- bt_component_class_sink_consume_method_status status =
- BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK;
- const bt_packet *ir_packet =
- bt_message_packet_beginning_borrow_packet_const(msg);
- const bt_stream *ir_stream = bt_packet_borrow_stream_const(ir_packet);
- struct fs_sink_stream *stream;
- const bt_clock_snapshot *cs = NULL;
-
- stream = borrow_stream(fs_sink, ir_stream);
- if (G_UNLIKELY(!stream)) {
- BT_COMP_LOGE_APPEND_CAUSE(fs_sink->self_comp,
- "Failed to borrow stream.");
- status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR;
- goto end;
- }
-
- if (stream->sc->packets_have_ts_begin) {
- cs = bt_message_packet_beginning_borrow_default_clock_snapshot_const(
- msg);
- BT_ASSERT(cs);
- }
-
- /*
- * If we previously received a discarded events message with
- * a time range, make sure that its beginning time matches what's
- * expected for CTF 1.8, that is:
- *
- * * Its beginning time is the previous packet's end
- * time (or the current packet's beginning time if
- * this is the first packet).
- *
- * We check this here instead of in handle_packet_end_msg()
- * because we want to catch any incompatible message as early as
- * possible to report the error.
- *
- * Validation of the discarded events message's end time is
- * performed in handle_packet_end_msg().
- */
- if (stream->discarded_events_state.in_range) {
- uint64_t expected_cs;
-
- /*
- * `stream->discarded_events_state.in_range` is only set
- * when the stream class's discarded events have a time
- * range.
- *
- * It is required that the packet beginning and end
- * messages for this stream class have times when
- * discarded events have a time range.
- */
- BT_ASSERT(stream->sc->discarded_events_has_ts);
- BT_ASSERT(stream->sc->packets_have_ts_begin);
- BT_ASSERT(stream->sc->packets_have_ts_end);
-
- if (stream->prev_packet_state.end_cs == UINT64_C(-1)) {
- /* We're opening the first packet */
- expected_cs = bt_clock_snapshot_get_value(cs);
- } else {
- expected_cs = stream->prev_packet_state.end_cs;
- }
-
- if (stream->discarded_events_state.beginning_cs !=
- expected_cs) {
- BT_COMP_LOGE_APPEND_CAUSE(fs_sink->self_comp,
- "Incompatible discarded events message: "
- "unexpected beginning time: "
- "beginning-cs-val=%" PRIu64 ", "
- "expected-beginning-cs-val=%" PRIu64 ", "
- "stream-id=%" PRIu64 ", stream-name=\"%s\", "
- "trace-name=\"%s\", path=\"%s/%s\"",
- stream->discarded_events_state.beginning_cs,
- expected_cs,
- bt_stream_get_id(ir_stream),
- bt_stream_get_name(ir_stream),
- bt_trace_get_name(
- bt_stream_borrow_trace_const(ir_stream)),
- stream->trace->path->str, stream->file_name->str);
- status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR;
- goto end;
- }
- }
-
- /*
- * If we previously received a discarded packets message with a
- * time range, make sure that its beginning and end times match
- * what's expected for CTF 1.8, that is:
- *
- * * Its beginning time is the previous packet's end time.
- *
- * * Its end time is the current packet's beginning time.
- */
- if (stream->discarded_packets_state.in_range) {
- uint64_t expected_end_cs;
-
- /*
- * `stream->discarded_packets_state.in_range` is only
- * set when the stream class's discarded packets have a
- * time range.
- *
- * It is required that the packet beginning and end
- * messages for this stream class have times when
- * discarded packets have a time range.
- */
- BT_ASSERT(stream->sc->discarded_packets_has_ts);
- BT_ASSERT(stream->sc->packets_have_ts_begin);
- BT_ASSERT(stream->sc->packets_have_ts_end);
-
- /*
- * It is not supported to have a discarded packets
- * message _before_ the first packet: we cannot validate
- * that its beginning time is compatible with CTF 1.8 in
- * this case.
- */
- if (stream->prev_packet_state.end_cs == UINT64_C(-1)) {
- BT_COMP_LOGE_APPEND_CAUSE(fs_sink->self_comp,
- "Incompatible discarded packets message "
- "occurring before the stream's first packet: "
- "stream-id=%" PRIu64 ", stream-name=\"%s\", "
- "trace-name=\"%s\", path=\"%s/%s\"",
- bt_stream_get_id(ir_stream),
- bt_stream_get_name(ir_stream),
- bt_trace_get_name(
- bt_stream_borrow_trace_const(ir_stream)),
- stream->trace->path->str, stream->file_name->str);
- status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR;
- goto end;
- }
-
- if (stream->discarded_packets_state.beginning_cs !=
- stream->prev_packet_state.end_cs) {
- BT_COMP_LOGE_APPEND_CAUSE(fs_sink->self_comp,
- "Incompatible discarded packets message: "
- "unexpected beginning time: "
- "beginning-cs-val=%" PRIu64 ", "
- "expected-beginning-cs-val=%" PRIu64 ", "
- "stream-id=%" PRIu64 ", stream-name=\"%s\", "
- "trace-name=\"%s\", path=\"%s/%s\"",
- stream->discarded_packets_state.beginning_cs,
- stream->prev_packet_state.end_cs,
- bt_stream_get_id(ir_stream),
- bt_stream_get_name(ir_stream),
- bt_trace_get_name(
- bt_stream_borrow_trace_const(ir_stream)),
- stream->trace->path->str, stream->file_name->str);
- status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR;
- goto end;
- }
-
- expected_end_cs = bt_clock_snapshot_get_value(cs);
-
- if (stream->discarded_packets_state.end_cs !=
- expected_end_cs) {
- BT_COMP_LOGE_APPEND_CAUSE(fs_sink->self_comp,
- "Incompatible discarded packets message: "
- "unexpected end time: "
- "end-cs-val=%" PRIu64 ", "
- "expected-end-cs-val=%" PRIu64 ", "
- "stream-id=%" PRIu64 ", stream-name=\"%s\", "
- "trace-name=\"%s\", path=\"%s/%s\"",
- stream->discarded_packets_state.end_cs,
- expected_end_cs,
- bt_stream_get_id(ir_stream),
- bt_stream_get_name(ir_stream),
- bt_trace_get_name(
- bt_stream_borrow_trace_const(ir_stream)),
- stream->trace->path->str, stream->file_name->str);
- status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR;
- goto end;
- }
- }
-
- /*
- * We're not in a discarded packets time range anymore since we
- * require that the discarded packets time ranges go from one
- * packet's end time to the next packet's beginning time, and
- * we're handling a packet beginning message here.
- */
- stream->discarded_packets_state.in_range = false;
-
- ret = fs_sink_stream_open_packet(stream, cs, ir_packet);
- if (ret) {
- BT_COMP_LOGE_APPEND_CAUSE(fs_sink->self_comp,
- "Failed to open packet.");
- status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR;
- goto end;
- }
+ int ret;
+ bt_component_class_sink_consume_method_status status =
+ BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK;
+ const bt_packet *ir_packet = bt_message_packet_beginning_borrow_packet_const(msg);
+ const bt_stream *ir_stream = bt_packet_borrow_stream_const(ir_packet);
+ struct fs_sink_stream *stream;
+ const bt_clock_snapshot *cs = NULL;
+
+ stream = borrow_stream(fs_sink, ir_stream);
+ if (G_UNLIKELY(!stream)) {
+ BT_COMP_LOGE_APPEND_CAUSE(fs_sink->self_comp, "Failed to borrow stream.");
+ status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR;
+ goto end;
+ }
+
+ if (stream->sc->packets_have_ts_begin) {
+ cs = bt_message_packet_beginning_borrow_default_clock_snapshot_const(msg);
+ BT_ASSERT(cs);
+ }
+
+ /*
+ * If we previously received a discarded events message with
+ * a time range, make sure that its beginning time matches what's
+ * expected for CTF 1.8, that is:
+ *
+ * * Its beginning time is the previous packet's end
+ * time (or the current packet's beginning time if
+ * this is the first packet).
+ *
+ * We check this here instead of in handle_packet_end_msg()
+ * because we want to catch any incompatible message as early as
+ * possible to report the error.
+ *
+ * Validation of the discarded events message's end time is
+ * performed in handle_packet_end_msg().
+ */
+ if (stream->discarded_events_state.in_range) {
+ uint64_t expected_cs;
+
+ /*
+ * `stream->discarded_events_state.in_range` is only set
+ * when the stream class's discarded events have a time
+ * range.
+ *
+ * It is required that the packet beginning and end
+ * messages for this stream class have times when
+ * discarded events have a time range.
+ */
+ BT_ASSERT(stream->sc->discarded_events_has_ts);
+ BT_ASSERT(stream->sc->packets_have_ts_begin);
+ BT_ASSERT(stream->sc->packets_have_ts_end);
+
+ if (stream->prev_packet_state.end_cs == UINT64_C(-1)) {
+ /* We're opening the first packet */
+ expected_cs = bt_clock_snapshot_get_value(cs);
+ } else {
+ expected_cs = stream->prev_packet_state.end_cs;
+ }
+
+ if (stream->discarded_events_state.beginning_cs != expected_cs) {
+ BT_COMP_LOGE_APPEND_CAUSE(fs_sink->self_comp,
+ "Incompatible discarded events message: "
+ "unexpected beginning time: "
+ "beginning-cs-val=%" PRIu64 ", "
+ "expected-beginning-cs-val=%" PRIu64 ", "
+ "stream-id=%" PRIu64 ", stream-name=\"%s\", "
+ "trace-name=\"%s\", path=\"%s/%s\"",
+ stream->discarded_events_state.beginning_cs, expected_cs,
+ bt_stream_get_id(ir_stream), bt_stream_get_name(ir_stream),
+ bt_trace_get_name(bt_stream_borrow_trace_const(ir_stream)),
+ stream->trace->path->str, stream->file_name->str);
+ status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR;
+ goto end;
+ }
+ }
+
+ /*
+ * If we previously received a discarded packets message with a
+ * time range, make sure that its beginning and end times match
+ * what's expected for CTF 1.8, that is:
+ *
+ * * Its beginning time is the previous packet's end time.
+ *
+ * * Its end time is the current packet's beginning time.
+ */
+ if (stream->discarded_packets_state.in_range) {
+ uint64_t expected_end_cs;
+
+ /*
+ * `stream->discarded_packets_state.in_range` is only
+ * set when the stream class's discarded packets have a
+ * time range.
+ *
+ * It is required that the packet beginning and end
+ * messages for this stream class have times when
+ * discarded packets have a time range.
+ */
+ BT_ASSERT(stream->sc->discarded_packets_has_ts);
+ BT_ASSERT(stream->sc->packets_have_ts_begin);
+ BT_ASSERT(stream->sc->packets_have_ts_end);
+
+ /*
+ * It is not supported to have a discarded packets
+ * message _before_ the first packet: we cannot validate
+ * that its beginning time is compatible with CTF 1.8 in
+ * this case.
+ */
+ if (stream->prev_packet_state.end_cs == UINT64_C(-1)) {
+ BT_COMP_LOGE_APPEND_CAUSE(fs_sink->self_comp,
+ "Incompatible discarded packets message "
+ "occurring before the stream's first packet: "
+ "stream-id=%" PRIu64 ", stream-name=\"%s\", "
+ "trace-name=\"%s\", path=\"%s/%s\"",
+ bt_stream_get_id(ir_stream), bt_stream_get_name(ir_stream),
+ bt_trace_get_name(bt_stream_borrow_trace_const(ir_stream)),
+ stream->trace->path->str, stream->file_name->str);
+ status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR;
+ goto end;
+ }
+
+ if (stream->discarded_packets_state.beginning_cs != stream->prev_packet_state.end_cs) {
+ BT_COMP_LOGE_APPEND_CAUSE(fs_sink->self_comp,
+ "Incompatible discarded packets message: "
+ "unexpected beginning time: "
+ "beginning-cs-val=%" PRIu64 ", "
+ "expected-beginning-cs-val=%" PRIu64 ", "
+ "stream-id=%" PRIu64 ", stream-name=\"%s\", "
+ "trace-name=\"%s\", path=\"%s/%s\"",
+ stream->discarded_packets_state.beginning_cs,
+ stream->prev_packet_state.end_cs, bt_stream_get_id(ir_stream),
+ bt_stream_get_name(ir_stream),
+ bt_trace_get_name(bt_stream_borrow_trace_const(ir_stream)),
+ stream->trace->path->str, stream->file_name->str);
+ status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR;
+ goto end;
+ }
+
+ expected_end_cs = bt_clock_snapshot_get_value(cs);
+
+ if (stream->discarded_packets_state.end_cs != expected_end_cs) {
+ BT_COMP_LOGE_APPEND_CAUSE(fs_sink->self_comp,
+ "Incompatible discarded packets message: "
+ "unexpected end time: "
+ "end-cs-val=%" PRIu64 ", "
+ "expected-end-cs-val=%" PRIu64 ", "
+ "stream-id=%" PRIu64 ", stream-name=\"%s\", "
+ "trace-name=\"%s\", path=\"%s/%s\"",
+ stream->discarded_packets_state.end_cs, expected_end_cs,
+ bt_stream_get_id(ir_stream), bt_stream_get_name(ir_stream),
+ bt_trace_get_name(bt_stream_borrow_trace_const(ir_stream)),
+ stream->trace->path->str, stream->file_name->str);
+ status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR;
+ goto end;
+ }
+ }
+
+ /*
+ * We're not in a discarded packets time range anymore since we
+ * require that the discarded packets time ranges go from one
+ * packet's end time to the next packet's beginning time, and
+ * we're handling a packet beginning message here.
+ */
+ stream->discarded_packets_state.in_range = false;
+
+ ret = fs_sink_stream_open_packet(stream, cs, ir_packet);
+ if (ret) {
+ BT_COMP_LOGE_APPEND_CAUSE(fs_sink->self_comp, "Failed to open packet.");
+ status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR;
+ goto end;
+ }