Skip to content

Commit

Permalink
Hopefully actually eliminated race
Browse files Browse the repository at this point in the history
  • Loading branch information
zasweq committed Jan 9, 2024
1 parent ea47cd6 commit 3d35b6d
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions xds/internal/xdsclient/authority.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ func (a *authority) startWatchTimersLocked(rType xdsresource.Type, resourceNames
continue
}
state.wTimer = time.AfterFunc(a.watchExpiryTimeout, func() {
a.handleWatchTimerExpiry(rType, resourceName)
a.handleWatchTimerExpiry(rType, resourceName, state)
})
state.wState = watchStateRequested
}
Expand Down Expand Up @@ -511,19 +511,13 @@ func (a *authority) watchResource(rType xdsresource.Type, resourceName string, w
}
}

func (a *authority) handleWatchTimerExpiry(rType xdsresource.Type, resourceName string) {
func (a *authority) handleWatchTimerExpiry(rType xdsresource.Type, resourceName string, state *resourceState) {
a.resourcesMu.Lock()
defer a.resourcesMu.Unlock()

if a.closed {
return
}
resourceStates := a.resources[rType]
state, ok := resourceStates[resourceName]
if !ok {
a.logger.Warningf("Watch for non-existent resource %q of type %s timed out", resourceName, rType.TypeName())
}

a.logger.Warningf("Watch for resource %q of type %s timed out", resourceName, rType.TypeName())

switch state.wState {
Expand Down Expand Up @@ -560,7 +554,9 @@ func (a *authority) triggerResourceNotFoundForTesting(rType xdsresource.Type, re
if !ok {
return
}

Check warning on line 556 in xds/internal/xdsclient/authority.go

View check run for this annotation

Codecov / codecov/patch

xds/internal/xdsclient/authority.go#L555-L556

Added lines #L555 - L556 were not covered by tests
if state.wState == watchStateCanceled {
// if watchStateTimeout already triggered resource not found above from
// normal watch expiry.
if state.wState == watchStateCanceled || state.wState == watchStateTimeout {
return
}

Check warning on line 561 in xds/internal/xdsclient/authority.go

View check run for this annotation

Codecov / codecov/patch

xds/internal/xdsclient/authority.go#L560-L561

Added lines #L560 - L561 were not covered by tests
state.wState = watchStateTimeout
Expand Down

0 comments on commit 3d35b6d

Please sign in to comment.