Fix: flt.utils.trimmer: accept inited streams ending without other messages
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 23 Apr 2019 21:38:20 +0000 (17:38 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 3 May 2019 22:19:39 +0000 (18:19 -0400)
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 <eeppeliteloop@gmail.com>
plugins/utils/trimmer/trimmer.c

index 7fd3279bf12bc5cb2ae29c6d177411d76c596e48..ddf95b9d1845b5802f1fc673a8b0d25fbc365435 100644 (file)
@@ -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) {
This page took 0.025369 seconds and 4 git commands to generate.