Skip to content

Commit 28ac6ef

Browse files
authored
xdsclient: make watch timer a no-op if authority is closed (#6502)
1 parent d06ab0d commit 28ac6ef

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

xds/internal/xdsclient/authority.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ type authority struct {
8383
// actual state of the resource.
8484
resourcesMu sync.Mutex
8585
resources map[xdsresource.Type]map[string]*resourceState
86+
closed bool
8687
}
8788

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

444445
func (a *authority) close() {
445446
a.transport.Close()
447+
448+
a.resourcesMu.Lock()
449+
a.closed = true
450+
a.resourcesMu.Unlock()
446451
}
447452

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

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

518+
if a.closed {
519+
return
520+
}
521+
a.logger.Warningf("Watch for resource %q of type %s timed out", resourceName, rType.TypeName())
522+
514523
switch state.wState {
515524
case watchStateRequested:
516525
// This is the only state where we need to handle the timer expiry by

0 commit comments

Comments
 (0)