mirror of
https://github.com/livekit/livekit.git
synced 2026-10-22 17:32:23 +00:00
ignore abnormal forward delay (#2748)
This commit is contained in:
1 parent
3ad0a69c86
commit
526d3a017e
1 file changed
+6
-1
@@ -27,13 +27,18 @@ func NewForwardStats(latencyUpdateInterval, reportInterval, latencyWindowLength
|
||||
}
|
||||
|
||||
func (s *ForwardStats) Update(arrival, left time.Time) {
|
||||
transit := left.Sub(arrival)
|
||||
|
||||
// ignore if transit is too large or negative, this could happen if system time is adjusted
|
||||
if transit < 0 || transit > 5*time.Second {
|
||||
return
|
||||
}
|
||||
leftMs := left.UnixMilli()
|
||||
lastMs := s.lastLeftMs.Load()
|
||||
if leftMs < lastMs || !s.lastLeftMs.CompareAndSwap(lastMs, leftMs) {
|
||||
return
|
||||
}
|
||||
|
||||
transit := left.Sub(arrival)
|
||||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
s.latency.Update(time.Duration(arrival.UnixNano()), float64(transit))
|
||||
|
||||
Reference in new issue
Block a user