Skip to content

Commit

Permalink
Merge pull request #887 from lk-j/v1.7.15-lock-change
Browse files Browse the repository at this point in the history
V1.7.15 lock change
  • Loading branch information
smallnest authored Jan 28, 2025
2 parents 0b3b436 + 7b272d9 commit 751e883
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions client/xclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,17 +326,17 @@ 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() {
c.mu.Unlock()
return client, nil
}
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) {
Expand All @@ -355,9 +355,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)
Expand Down

0 comments on commit 751e883

Please sign in to comment.