From cd0359c89863852a55d956ee465d42c029fc7604 Mon Sep 17 00:00:00 2001 From: Raja Subramanian Date: Thu, 23 Feb 2023 09:39:33 +0530 Subject: [PATCH] Reset subscription start timer on permission grant. (#1457) If not, bind timeout could be reported on permission grant as it could be using some old timer. --- pkg/rtc/subscriptionmanager.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/rtc/subscriptionmanager.go b/pkg/rtc/subscriptionmanager.go index d60a3766b..e41fbade9 100644 --- a/pkg/rtc/subscriptionmanager.go +++ b/pkg/rtc/subscriptionmanager.go @@ -420,6 +420,11 @@ func (m *SubscriptionManager) subscribe(s *trackSubscription) error { permChanged := s.setHasPermission(res.HasPermission) if permChanged { m.params.Participant.SubscriptionPermissionUpdate(s.getPublisherID(), s.trackID, res.HasPermission) + if res.HasPermission { + // when permission is granted, reset the timer so it has sufficient time to reconcile + t := time.Now() + s.subStartedAt.Store(&t) + } } if !res.HasPermission { return ErrNoTrackPermission @@ -578,7 +583,7 @@ type trackSubscription struct { numAttempts atomic.Int32 bound bool - // the later of when subscription was requested or when the first failure was encountered + // the later of when subscription was requested OR when the first failure was encountered OR when permission is granted // this timestamp determines when failures are reported subStartedAt atomic.Pointer[time.Time] }