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.
This commit is contained in:
Raja Subramanian
2023-02-23 09:39:33 +05:30
committed by GitHub
parent 15232560bc
commit cd0359c898
+6 -1
View File
@@ -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]
}