From 28b1cfc617d12a605a34ea9060102334cd86fe95 Mon Sep 17 00:00:00 2001 From: Sergio Ammirata Date: Fri, 26 Jun 2026 08:15:42 -0400 Subject: [PATCH] fix(receiver): clear stale clock-drift samples on a framing-baseline reset (#218) Forwarded: https://code.videolan.org/rist/librist/-/work_items/218 When an Advanced flow upgrades from Main to Advanced wire framing mid-stream, the two framings carry source_time in different timestamp domains, so the switch resets the flow timing baseline. That reset re-derived time_offset but left the clock-drift sample buffer full of stale Main-domain samples. The next median recalculation then jumped the offset by several seconds and released the whole receiver buffer at once, overflowing the data-out fifo. Because test_send_receive treats any ERROR-level log as fatal at 0% loss, the single "Rist data out fifo queue overflow" line failed the advanced+unicast+client tests, most reproducibly on slower build hosts. Clear the drift samples on the baseline reset, matching the existing clock-wrap reset path. Thanks to Florian Ernst for the detailed report and build logs. --- src/rist-common.c | 8 ++++++++ 1 files changed, 8 insertions(+) diff --git a/src/rist-common.c b/src/rist-common.c index 200598db..7965231d 100755 --- a/src/rist-common.c +++ b/src/rist-common.c @@ -747,6 +747,14 @@ static int receiver_enqueue(struct rist_peer *peer, uint64_t source_time, uint64 f->last_packet_ts = packet_time; f->time_offset_changed_ts = 0; f->time_offset_old = f->time_offset; + /* Discard clock-drift samples gathered against the previous + * baseline. A flow-id change or a Main<->Advanced wire-framing + * switch (the two framings carry source_time in different + * timestamp domains) lands here with stale samples still queued; + * blending them into the median yields a bogus multi-second + * offset correction that releases the whole buffer at once and + * overflows the data-out fifo. Matches the clock-wrap reset. */ + f->offset_recalc_sample_count = 0; receiver_insert_queue_packet(f, peer, idx_initial, buf, len, seq, source_time, src_port, dst_port, packet_time); atomic_store_explicit(&f->receiver_queue_output_idx, idx_initial, memory_order_release); -- GitLab