From 02eef30722e5727a29512940a792125b29c41902 Mon Sep 17 00:00:00 2001 From: Vee Zhang Date: Tue, 29 Nov 2022 21:09:43 +0800 Subject: [PATCH] fix: client blocking when connecting --- ccore/nebula/gateway/pool/pool.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ccore/nebula/gateway/pool/pool.go b/ccore/nebula/gateway/pool/pool.go index 690e699..d788fea 100644 --- a/ccore/nebula/gateway/pool/pool.go +++ b/ccore/nebula/gateway/pool/pool.go @@ -213,8 +213,6 @@ func ListParams(args string, tmpParameter types.ParameterMap, sessionMap types.P func NewClient(address string, port int, username string, password string, opts ...nebula.Option) (*ClientInfo, error) { var err error - clientMux.Lock() - defer clientMux.Unlock() // TODO: it's better to add a schedule to make it instead if currentClientNum > clientRecycleNum { @@ -253,8 +251,11 @@ func NewClient(address string, port int, username string, password string, opts }, timezone: c.GetTimezoneInfo(), } + + clientMux.Lock() clientPool[nsid] = client currentClientNum++ + clientMux.Unlock() // Make a goroutine to deal with concurrent requests from each connection go handleRequest(nsid)