Skip to content
Snippets Groups Projects
Commit 8f61206c authored by 邹毅贤's avatar 邹毅贤
Browse files

change lock granularity

parent e743230f
No related branches found
No related tags found
No related merge requests found
......@@ -58,13 +58,13 @@ func (l *RegistryDataListener) SubscribeURL(url *common.URL, listener config_cen
// SubscribeURL is used to set a watch listener for url
func (l *RegistryDataListener) UnSubscribeURL(url *common.URL) config_center.ConfigurationListener {
l.mutex.Lock()
defer l.mutex.Unlock()
if l.closed {
return nil
}
l.mutex.Lock()
listener := l.subscribed[url]
delete(l.subscribed, url)
l.mutex.Unlock()
return listener
}
......
......@@ -285,16 +285,19 @@ func (r *zkRegistry) getCloseListener(conf *common.URL) (*RegistryConfigurationL
}
}
zkListener = r.dataListener.UnSubscribeURL(conf).(*RegistryConfigurationListener)
zkListener = dataListener.UnSubscribeURL(conf).(*RegistryConfigurationListener)
if r.listener == nil {
return nil, perrors.New("listener is null can not close.")
}
//Interested register to dataconfig.
r.listenerLock.Lock()
r.dataListener.Close()
r.listener.Close()
listener := r.listener
r.listener = nil
r.listenerLock.Unlock()
dataListener.Close()
listener.Close()
return zkListener, 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