Skip to content

Commit

Permalink
return err if clients fail to connect
Browse files Browse the repository at this point in the history
  • Loading branch information
smallnest committed Jan 28, 2025
1 parent 751e883 commit 675b720
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions client/xclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,11 @@ func safeCloseClient(client RPCClient) {
client.Close()
}

func (c *xClient) getCachedClient(k string, servicePath, serviceMethod string, args interface{}) (RPCClient, error) {
// TODO: improve the lock
var client RPCClient
func (c *xClient) getCachedClient(k string, servicePath, serviceMethod string, _ interface{}) (client RPCClient, err error) {
var needCallPlugin bool
defer func() {
if needCallPlugin {
c.Plugins.DoClientConnected(client.GetConn())
_, err = c.Plugins.DoClientConnected(client.GetConn())
}
}()

Expand All @@ -327,15 +325,15 @@ 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() {
return client, nil
}
c.deleteCachedClient(client, k, servicePath, serviceMethod)
}

client = c.findCachedClient(k, servicePath, serviceMethod)

if client == nil || client.IsShutdown() {
Expand Down

0 comments on commit 675b720

Please sign in to comment.