Skip to content

Commit

Permalink
Switched unlock to defer in newAddrConn (#5556)
Browse files Browse the repository at this point in the history
  • Loading branch information
zasweq committed Aug 2, 2022
1 parent 57aaa10 commit a077b94
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions clientconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,8 @@ func (cc *ClientConn) newAddrConn(addrs []resolver.Address, opts balancer.NewSub
ac.ctx, ac.cancel = context.WithCancel(cc.ctx)
// Track ac in cc. This needs to be done before any getTransport(...) is called.
cc.mu.Lock()
defer cc.mu.Unlock()
if cc.conns == nil {
cc.mu.Unlock()
return nil, ErrClientConnClosing
}

Expand All @@ -732,7 +732,6 @@ func (cc *ClientConn) newAddrConn(addrs []resolver.Address, opts balancer.NewSub
})

cc.conns[ac] = struct{}{}
cc.mu.Unlock()
return ac, nil
}

Expand Down

0 comments on commit a077b94

Please sign in to comment.