From 63393f1deb30144b83f9cb0442bdc98e546f90e4 Mon Sep 17 00:00:00 2001
From: pantianying <601666418@qq.com>
Date: Fri, 30 Aug 2019 12:57:24 +0800
Subject: [PATCH] fix deadlock

---
 protocol/dubbo/pool.go | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/protocol/dubbo/pool.go b/protocol/dubbo/pool.go
index 546a5b335..9beb221af 100644
--- a/protocol/dubbo/pool.go
+++ b/protocol/dubbo/pool.go
@@ -275,6 +275,7 @@ func (p *gettyRPCClientPool) close() {
 func (p *gettyRPCClientPool) getGettyRpcClient(protocol, addr string) (*gettyRPCClient, error) {
 
 	p.Lock()
+	defer p.Unlock()
 	if p.conns == nil {
 		return nil, errClientPoolClosed
 	}
@@ -290,12 +291,10 @@ func (p *gettyRPCClientPool) getGettyRpcClient(protocol, addr string) (*gettyRPC
 			continue
 		}
 		conn.created = now //update created time
-
-		p.Unlock()
 		return conn, nil
 	}
 	// create new conn
-	p.Unlock()
+
 	return newGettyRPCClientConn(p, protocol, addr)
 }
 
-- 
GitLab