From 09f70e8e597866d2cfce8e99b5fec7a79e5d511e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98lk-j?= <381584494@qq.com> Date: Tue, 14 Jan 2025 15:44:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=81=E7=9A=84?= =?UTF-8?q?=E7=B2=92=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/xclient.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/client/xclient.go b/client/xclient.go index 3ead82f5..b5bb5bd1 100644 --- a/client/xclient.go +++ b/client/xclient.go @@ -300,6 +300,8 @@ func (c *xClient) getCachedClient(k string, servicePath, serviceMethod string, a } c.mu.Lock() + defer c.mu.Unlock() + client = c.findCachedClient(k, servicePath, serviceMethod) if client != nil { if !client.IsClosing() && !client.IsShutdown() { @@ -308,9 +310,8 @@ func (c *xClient) getCachedClient(k string, servicePath, serviceMethod string, a } c.deleteCachedClient(client, k, servicePath, serviceMethod) } - + client = c.findCachedClient(k, servicePath, serviceMethod) - c.mu.Unlock() if client == nil || client.IsShutdown() { generatedClient, err, _ := c.slGroup.Do(k, func() (interface{}, error) { @@ -329,9 +330,7 @@ func (c *xClient) getCachedClient(k string, servicePath, serviceMethod string, a client.RegisterServerMessageChan(c.serverMessageChan) - c.mu.Lock() c.setCachedClient(client, k, servicePath, serviceMethod) - c.mu.Unlock() // forget k only when client is cached c.slGroup.Forget(k) From 7b272d960f79b49ff215f1b13948e86b02768c5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98lk-j?= <381584494@qq.com> Date: Tue, 14 Jan 2025 15:56:48 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=81=E7=9A=84?= =?UTF-8?q?=E7=B2=92=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/xclient.go | 1 - 1 file changed, 1 deletion(-) diff --git a/client/xclient.go b/client/xclient.go index b5bb5bd1..b14765e0 100644 --- a/client/xclient.go +++ b/client/xclient.go @@ -305,7 +305,6 @@ func (c *xClient) getCachedClient(k string, servicePath, serviceMethod string, a client = c.findCachedClient(k, servicePath, serviceMethod) if client != nil { if !client.IsClosing() && !client.IsShutdown() { - c.mu.Unlock() return client, nil } c.deleteCachedClient(client, k, servicePath, serviceMethod)