Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xdsclient: release lock before attempting to close underlying transport #8011

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions xds/internal/xdsclient/client_refcounted.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,24 @@

func clientRefCountedClose(name string) {
clientsMu.Lock()
defer clientsMu.Unlock()

client, ok := clients[name]
if !ok {
logger.Errorf("Attempt to close a non-existent xDS client with name %s", name)
clientsMu.Unlock()

Check warning on line 46 in xds/internal/xdsclient/client_refcounted.go

View check run for this annotation

Codecov / codecov/patch

xds/internal/xdsclient/client_refcounted.go#L46

Added line #L46 was not covered by tests
return
}
if client.decrRef() != 0 {
clientsMu.Unlock()
return
}
delete(clients, name)
clientsMu.Unlock()

// This attempts to close the transport to the management server and could
// theoretically call back into the xdsclient package again and deadlock.
// Hence, this needs to be called without holding the lock.
client.clientImpl.close()
xdsClientImplCloseHook(name)
delete(clients, name)

}

Expand Down
Loading