From c24092f22c45c5d827ff66303d1b5ca7b8f99991 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Tue, 23 Apr 2019 17:38:20 -0400 Subject: [PATCH] Fix: flt.utils.trimmer: accept inited streams ending without other messages Issue ===== It is possible that, for a given stream, an `flt.utils.trimmer` component receives the stream beginning and stream beginnin activity messages, and then it needs to be ended. In this case, `sstate->stream_act_end_ns_from_origin` is never set, so we hit the assertion. Solution ======== When ending a stream and when `sstate->stream_act_end_ns_from_origin` is not set for this stream, use the trimming range's end time as the stream activity end time. If `sstate->stream_act_end_ns_from_origin` is not set at this point, then we know the stream is currently active, so it is safe to use a specific time as its activity end time. If the last received message for this stream was a stream activity end message, then we don't reach this code because it's conditional to `!sstate->last_msg_is_stream_activity_end`. Known drawbacks =============== None. Signed-off-by: Philippe Proulx --- plugins/utils/trimmer/trimmer.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/utils/trimmer/trimmer.c b/plugins/utils/trimmer/trimmer.c index 7fd3279b..ddf95b9d 100644 --- a/plugins/utils/trimmer/trimmer.c +++ b/plugins/utils/trimmer/trimmer.c @@ -1024,7 +1024,19 @@ bt_self_message_iterator_status end_stream(struct trimmer_iterator *trimmer_it, clock_class = bt_stream_class_borrow_default_clock_class_const( bt_stream_borrow_class_const(sstate->stream)); BT_ASSERT(clock_class); - BT_ASSERT(sstate->stream_act_end_ns_from_origin != INT64_MIN); + + if (sstate->stream_act_end_ns_from_origin == INT64_MIN) { + /* + * We received at least what is necessary to + * have a stream state (stream beginning and + * stream activity beginning messages), but + * nothing else: use the trimmer range's end + * time. + */ + sstate->stream_act_end_ns_from_origin = + trimmer_it->end.ns_from_origin; + } + ret = clock_raw_value_from_ns_from_origin(clock_class, sstate->stream_act_end_ns_from_origin, &raw_value); if (ret) { -- 2.34.1