mirror of
https://github.com/smallnest/rpcx.git
synced 2025-11-02 20:24:02 +08:00
return err in case of fetching cached clients if this xclient is closed
This commit is contained in:
@@ -244,12 +244,16 @@ func (c *xClient) getCachedClient(k string) (RPCClient, error) {
|
|||||||
var client RPCClient
|
var client RPCClient
|
||||||
var needCallPlugin bool
|
var needCallPlugin bool
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
|
defer c.mu.Unlock()
|
||||||
defer func() {
|
defer func() {
|
||||||
if needCallPlugin {
|
if needCallPlugin {
|
||||||
c.Plugins.DoClientConnected((client.(*Client)).Conn)
|
c.Plugins.DoClientConnected((client.(*Client)).Conn)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
defer c.mu.Unlock()
|
|
||||||
|
if c.isShutdown {
|
||||||
|
return nil, errors.New("this xclient is closed")
|
||||||
|
}
|
||||||
|
|
||||||
breaker, ok := c.breakers.Load(k)
|
breaker, ok := c.breakers.Load(k)
|
||||||
if ok && !breaker.(Breaker).Ready() {
|
if ok && !breaker.(Breaker).Ready() {
|
||||||
@@ -932,10 +936,9 @@ loop:
|
|||||||
|
|
||||||
// Close closes this client and its underlying connnections to services.
|
// Close closes this client and its underlying connnections to services.
|
||||||
func (c *xClient) Close() error {
|
func (c *xClient) Close() error {
|
||||||
c.isShutdown = true
|
|
||||||
|
|
||||||
var errs []error
|
var errs []error
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
|
c.isShutdown = true
|
||||||
for k, v := range c.cachedClient {
|
for k, v := range c.cachedClient {
|
||||||
e := v.Close()
|
e := v.Close()
|
||||||
if e != nil {
|
if e != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user