From c627227a6634e1c7f7e85e72eb00fa9b894de779 Mon Sep 17 00:00:00 2001 From: pantianying <601666418@qq.com> Date: Wed, 18 Dec 2019 15:50:55 +0800 Subject: [PATCH] change the position of the lock --- protocol/dubbo/pool.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/protocol/dubbo/pool.go b/protocol/dubbo/pool.go index d619a2f8f..0c4e74ae7 100644 --- a/protocol/dubbo/pool.go +++ b/protocol/dubbo/pool.go @@ -291,8 +291,8 @@ func (p *gettyRPCClientPool) close() { func (p *gettyRPCClientPool) getGettyRpcClient(protocol, addr string) (*gettyRPCClient, error) { p.Lock() - defer p.Unlock() if p.conns == nil { + p.Unlock() return nil, errClientPoolClosed } @@ -308,9 +308,10 @@ func (p *gettyRPCClientPool) getGettyRpcClient(protocol, addr string) (*gettyRPC continue } conn.updateActive(now) //update active time - + p.Unlock() return conn, nil } + p.Unlock() // create new conn return newGettyRPCClientConn(p, protocol, addr) } -- GitLab