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:
@@ -420,6 +420,11 @@ func (m *SubscriptionManager) subscribe(s *trackSubscription) error {
|
|||||||
permChanged := s.setHasPermission(res.HasPermission)
|
permChanged := s.setHasPermission(res.HasPermission)
|
||||||
if permChanged {
|
if permChanged {
|
||||||
m.params.Participant.SubscriptionPermissionUpdate(s.getPublisherID(), s.trackID, res.HasPermission)
|
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 {
|
if !res.HasPermission {
|
||||||
return ErrNoTrackPermission
|
return ErrNoTrackPermission
|
||||||
@@ -578,7 +583,7 @@ type trackSubscription struct {
|
|||||||
numAttempts atomic.Int32
|
numAttempts atomic.Int32
|
||||||
bound bool
|
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
|
// this timestamp determines when failures are reported
|
||||||
subStartedAt atomic.Pointer[time.Time]
|
subStartedAt atomic.Pointer[time.Time]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user