Skip to content
Snippets Groups Projects
Commit ec1eff9f authored by pantianying's avatar pantianying
Browse files

add code

parent d359c34c
No related branches found
No related tags found
No related merge requests found
......@@ -74,11 +74,12 @@ type RegistryConfigurationListener struct {
client *zk.ZookeeperClient
registry *zkRegistry
events chan *config_center.ConfigChangeEvent
isClosed bool
}
func NewRegistryConfigurationListener(client *zk.ZookeeperClient, reg *zkRegistry) *RegistryConfigurationListener {
reg.wg.Add(1)
return &RegistryConfigurationListener{client: client, registry: reg, events: make(chan *config_center.ConfigChangeEvent, 32)}
return &RegistryConfigurationListener{client: client, registry: reg, events: make(chan *config_center.ConfigChangeEvent, 32), isClosed: false}
}
func (l *RegistryConfigurationListener) Process(configType *config_center.ConfigChangeEvent) {
l.events <- configType
......@@ -114,6 +115,7 @@ func (l *RegistryConfigurationListener) Close() {
* if the registry is not available, it means that the registry has been destroy
* so we don't need to call Done(), or it will cause the negative count panic for registry.wg
*/
l.isClosed = true
l.registry.wg.Done()
}
}
......
......@@ -453,6 +453,10 @@ func (r *zkRegistry) getListener(conf *common.URL) (*RegistryConfigurationListen
)
r.listenerLock.Lock()
if r.configListener.isClosed {
return nil, perrors.New("configListener already been closed")
r.listenerLock.Unlock()
}
zkListener = r.configListener
r.listenerLock.Unlock()
if r.listener == nil {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment