Skip to content

Commit

Permalink
lock during checkStats to avoid race if stats are updated while checking
Browse files Browse the repository at this point in the history
  • Loading branch information
dfawley committed Dec 12, 2019
1 parent 4fef929 commit b9945f4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions balancer/grpclb/grpclb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,10 @@ func (failPreRPCCred) RequireTransportSecurity() bool {

func checkStats(stats, expected *rpcStats) error {
if !stats.equal(expected) {
stats.mu.Lock()
defer stats.mu.Unlock()
expected.mu.Lock()
defer expected.mu.Unlock()
return fmt.Errorf("stats not equal: got %+v, want %+v", stats, expected)
}
return nil
Expand Down

0 comments on commit b9945f4

Please sign in to comment.