Skip to content

Remove unmeaning logic #855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions registry/zookeeper/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func (l *RegistryDataListener) DataChange(eventType remoting.Event) bool {
func (l *RegistryDataListener) Close() {
l.mutex.Lock()
defer l.mutex.Unlock()
l.closed = true
for _, listener := range l.subscribed {
listener.(*RegistryConfigurationListener).Close()
}
Expand Down
10 changes: 5 additions & 5 deletions registry/zookeeper/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ func (r *zkRegistry) InitListeners() {
oldDataListener := r.dataListener
oldDataListener.mutex.Lock()
defer oldDataListener.mutex.Unlock()
recoverd := r.dataListener.subscribed
if recoverd != nil && len(recoverd) > 0 {
r.dataListener.closed = true
recovered := r.dataListener.subscribed
if recovered != nil && len(recovered) > 0 {
// recover all subscribed url
for _, oldListener := range recoverd {
for _, oldListener := range recovered {
var (
regConfigListener *RegistryConfigurationListener
ok bool
)

if regConfigListener, ok = oldListener.(*RegistryConfigurationListener); ok {
regConfigListener.Close()
}
Expand Down Expand Up @@ -292,10 +292,10 @@ func (r *zkRegistry) getCloseListener(conf *common.URL) (*RegistryConfigurationL
r.dataListener.mutex.Lock()
configurationListener := r.dataListener.subscribed[conf.ServiceKey()]
if configurationListener != nil {

zkListener, _ := configurationListener.(*RegistryConfigurationListener)
if zkListener != nil {
if zkListener.isClosed {
r.dataListener.mutex.Unlock()
return nil, perrors.New("configListener already been closed")
}
}
Expand Down