Skip to content

Commit

Permalink
xdsclient: fix race in load report implementation (#5927)
Browse files Browse the repository at this point in the history
  • Loading branch information
easwars committed Jan 13, 2023
1 parent 2a9e970 commit 78ddc05
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion xds/internal/xdsclient/clientimpl_loadreport.go
Expand Up @@ -30,13 +30,15 @@ import (
func (c *clientImpl) ReportLoad(server *bootstrap.ServerConfig) (*load.Store, func()) {
c.authorityMu.Lock()
a, err := c.newAuthorityLocked(server)
c.authorityMu.Unlock()
if err != nil {
c.authorityMu.Unlock()
c.logger.Infof("xds: failed to connect to the control plane to do load reporting for authority %q: %v", server, err)
return nil, func() {}
}
// Hold the ref before starting load reporting.
a.refLocked()
c.authorityMu.Unlock()

store, cancelF := a.reportLoad()
return store, func() {
cancelF()
Expand Down

0 comments on commit 78ddc05

Please sign in to comment.