Skip to content

Commit

Permalink
xdsclient: make watch timer a no-op if authority is closed (grpc#6502)
Browse files Browse the repository at this point in the history
  • Loading branch information
easwars authored Aug 4, 2023
1 parent d06ab0d commit 28ac6ef
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion xds/internal/xdsclient/authority.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ type authority struct {
// actual state of the resource.
resourcesMu sync.Mutex
resources map[xdsresource.Type]map[string]*resourceState
closed bool
}

// authorityArgs is a convenience struct to wrap arguments required to create a
Expand Down Expand Up @@ -443,6 +444,10 @@ func (a *authority) unrefLocked() int {

func (a *authority) close() {
a.transport.Close()

a.resourcesMu.Lock()
a.closed = true
a.resourcesMu.Unlock()
}

func (a *authority) watchResource(rType xdsresource.Type, resourceName string, watcher xdsresource.ResourceWatcher) func() {
Expand Down Expand Up @@ -507,10 +512,14 @@ func (a *authority) watchResource(rType xdsresource.Type, resourceName string, w
}

func (a *authority) handleWatchTimerExpiry(rType xdsresource.Type, resourceName string, state *resourceState) {
a.logger.Warningf("Watch for resource %q of type %s timed out", resourceName, rType.TypeName())
a.resourcesMu.Lock()
defer a.resourcesMu.Unlock()

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

switch state.wState {
case watchStateRequested:
// This is the only state where we need to handle the timer expiry by
Expand Down

0 comments on commit 28ac6ef

Please sign in to comment.