Skip to content

Commit

Permalink
waitgroup and vet
Browse files Browse the repository at this point in the history
  • Loading branch information
menghanl committed Oct 23, 2019
1 parent 6772139 commit 46a2366
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions balancer/grpclb/grpclb_remote_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ func (lb *lbBalancer) refreshSubConns(backendAddrs []resolver.Address, fallback
fallbackModeChanged := lb.inFallback != fallback
lb.inFallback = fallback
if fallbackModeChanged && lb.inFallback {
// Clear previous received list, so if the server is back and sends the
// same list again, the new addresses will be used.
// Clear previous received list when entering fallback, so if the server
// comes back and sends the same list again, the new addresses will be
// used.
lb.fullServerList = nil
}

Expand Down Expand Up @@ -256,6 +257,7 @@ func (lb *lbBalancer) newRemoteBalancerCCWrapper() {
done: make(chan struct{}),
}
lb.ccRemoteLB = ccw
ccw.wg.Add(1)
go ccw.watchRemoteBalancer()
}

Expand Down Expand Up @@ -342,8 +344,8 @@ func (ccw *remoteBalancerCCWrapper) callRemoteBalancer() (backoff bool, _ error)
return true, fmt.Errorf("grpclb: Delegation is not supported")
}

ccw.wg.Add(1)
go func() {
ccw.wg.Add(1)
defer ccw.wg.Done()
if d := convertDuration(initResp.ClientStatsReportInterval); d > 0 {
ccw.sendLoadReport(stream, d)
Expand All @@ -354,7 +356,6 @@ func (ccw *remoteBalancerCCWrapper) callRemoteBalancer() (backoff bool, _ error)
}

func (ccw *remoteBalancerCCWrapper) watchRemoteBalancer() {
ccw.wg.Add(1)
defer ccw.wg.Done()
var retryCount int
for {
Expand Down
1 change: 1 addition & 0 deletions vet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ fi
staticcheck -go 1.9 -checks 'inherit,-ST1015' -ignore '
google.golang.org/grpc/balancer.go:SA1019
google.golang.org/grpc/balancer/grpclb/grpclb_remote_balancer.go:SA1019
google.golang.org/grpc/balancer/grpclb/grpclb_test.go:SA1019
google.golang.org/grpc/balancer/roundrobin/roundrobin_test.go:SA1019
google.golang.org/grpc/xds/internal/balancer/edsbalancer/balancergroup.go:SA1019
google.golang.org/grpc/xds/internal/resolver/xds_resolver.go:SA1019
Expand Down

0 comments on commit 46a2366

Please sign in to comment.