File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ type ConfigClient struct {
6060 cacheMap cache.ConcurrentMap
6161 uid string
6262 listenExecute chan struct {}
63+ isClosed bool
6364}
6465
6566type cacheData struct {
@@ -364,8 +365,15 @@ func (client *ConfigClient) SearchConfig(param vo.SearchConfigParam) (*model.Con
364365}
365366
366367func (client * ConfigClient ) CloseClient () {
368+ client .mutex .Lock ()
369+ defer client .mutex .Unlock ()
370+
371+ if client .isClosed {
372+ return
373+ }
367374 client .configProxy .getRpcClient (client ).Shutdown ()
368375 client .cancel ()
376+ client .isClosed = true
369377}
370378
371379func (client * ConfigClient ) searchConfigInner (param vo.SearchConfigParam ) (* model.ConfigPage , error ) {
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import (
2222 "math"
2323 "math/rand"
2424 "strings"
25+ "sync"
2526 "time"
2627
2728 "github.com/pkg/errors"
@@ -43,6 +44,8 @@ type NamingClient struct {
4344 cancel context.CancelFunc
4445 serviceProxy naming_proxy.INamingProxy
4546 serviceInfoHolder * naming_cache.ServiceInfoHolder
47+ isClosed bool
48+ mutex sync.Mutex
4649}
4750
4851// NewNamingClient ...
@@ -356,6 +359,13 @@ func (sc *NamingClient) ServerHealthy() bool {
356359
357360// CloseClient ...
358361func (sc * NamingClient ) CloseClient () {
362+ sc .mutex .Lock ()
363+ defer sc .mutex .Unlock ()
364+
365+ if sc .isClosed {
366+ return
367+ }
359368 sc .serviceProxy .CloseClient ()
360369 sc .cancel ()
370+ sc .isClosed = true
361371}
You can’t perform that action at this time.
0 commit comments