From 2d1f556794ae9111feea1e91d0371f134f906ac7 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Wed, 12 Jun 2024 17:50:03 +1000 Subject: [PATCH] rtp/session: guard against a busy wait with no members If the number of members is 0, then the calculated time to the next rtcp wakup would be 'now' and could result in a busy loop in the rtcp processing. Part-of: --- net/rtp/src/rtpbin2/session.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/rtp/src/rtpbin2/session.rs b/net/rtp/src/rtpbin2/session.rs index 7a8b82b7..640cbde7 100644 --- a/net/rtp/src/rtpbin2/session.rs +++ b/net/rtp/src/rtpbin2/session.rs @@ -1352,8 +1352,10 @@ impl Session { "members {n}, RTCP bandwidth {rtcp_bw}, average RTCP size {}", self.average_rtcp_size ); - let t_nanos = (compensation_ns - .mul_div_round(self.average_rtcp_size as u64 * n, rtcp_bw.max(1) as u64)) + let t_nanos = (compensation_ns.mul_div_round( + self.average_rtcp_size as u64 * n.max(1), + rtcp_bw.max(1) as u64, + )) .unwrap() .max(min_rtcp_interval.as_nanos() as u64); trace!("deterministic rtcp interval {t_nanos}ns");