Skip to content

Commit

Permalink
修复map加锁无效
Browse files Browse the repository at this point in the history
  • Loading branch information
ouqiang committed Jun 26, 2017
1 parent 3e8c3a2 commit 3d61c76
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion modules/rpc/grpcpool/grpc_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,18 @@ type GRPCPool struct {

func (p *GRPCPool) Get(addr string) (*grpc.ClientConn, error) {
p.RLock()
defer p.RUnlock()
pool, ok := p.conns[addr]
p.RUnlock()
if !ok {
err := p.newCommonPool(addr)
if err != nil {
return nil, err
}
}

p.RLock()
pool = p.conns[addr]
p.RUnlock()
conn, err := pool.Get()
if err != nil {
return nil, err
Expand Down

0 comments on commit 3d61c76

Please sign in to comment.