Skip to content

Commit

Permalink
grpc: Defer the unlock in newCCResolverWrapper (#3255)
Browse files Browse the repository at this point in the history
Although the existing code wasn't causing a deadlock or causing
goroutines to hang forever, this is cleaner and prevents any such thing
from happening in the future.
  • Loading branch information
easwars authored Dec 13, 2019
1 parent 085c980 commit e3baa76
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion resolver_conn_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ func newCCResolverWrapper(cc *ClientConn) (*ccResolverWrapper, error) {
// rb.Build-->ccr.ReportError-->ccr.poll-->ccr.resolveNow, would end up
// accessing ccr.resolver which is being assigned here.
ccr.resolverMu.Lock()
defer ccr.resolverMu.Unlock()
ccr.resolver, err = rb.Build(cc.parsedTarget, ccr, rbo)
if err != nil {
return nil, err
}
ccr.resolverMu.Unlock()
return ccr, nil
}

Expand Down

0 comments on commit e3baa76

Please sign in to comment.