You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by jo...@apache.org on 2020/07/07 07:14:45 UTC

[dubbo-go] branch develop updated: fix waitGroup

This is an automated email from the ASF dual-hosted git repository.

joezou pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/develop by this push:
     new 7aab577  fix waitGroup
     new 5bee5b6  Merge pull request #644 from pantianying/fix_waitgroup_develop
7aab577 is described below

commit 7aab5775f5d897a3b0da519576c10adb311fe095
Author: pantianying <pa...@gmail.com>
AuthorDate: Sat Jul 4 14:46:47 2020 +0800

    fix waitGroup
---
 registry/zookeeper/listener.go |  1 -
 registry/zookeeper/registry.go |  3 ++-
 remoting/zookeeper/listener.go | 12 ++++++++++--
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/registry/zookeeper/listener.go b/registry/zookeeper/listener.go
index c5b2f33..816e39b 100644
--- a/registry/zookeeper/listener.go
+++ b/registry/zookeeper/listener.go
@@ -111,7 +111,6 @@ type RegistryConfigurationListener struct {
 
 // NewRegistryConfigurationListener for listening the event of zk.
 func NewRegistryConfigurationListener(client *zk.ZookeeperClient, reg *zkRegistry) *RegistryConfigurationListener {
-	reg.WaitGroup().Add(1)
 	return &RegistryConfigurationListener{client: client, registry: reg, events: make(chan *config_center.ConfigChangeEvent, 32), isClosed: false, close: make(chan struct{}, 1)}
 }
 
diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go
index 1e7bd08..04316bd 100644
--- a/registry/zookeeper/registry.go
+++ b/registry/zookeeper/registry.go
@@ -134,6 +134,7 @@ func (r *zkRegistry) InitListeners() {
 					regConfigListener.Close()
 				}
 				newDataListener.SubscribeURL(conf, NewRegistryConfigurationListener(r.client, r))
+				r.WaitGroup().Add(1)
 				go r.listener.ListenServiceEvent(conf, fmt.Sprintf("/dubbo/%s/"+constant.DEFAULT_CATEGORY, url.QueryEscape(conf.Service())), newDataListener)
 
 			}
@@ -259,7 +260,7 @@ func (r *zkRegistry) getListener(conf *common.URL) (*RegistryConfigurationListen
 
 	//Interested register to dataconfig.
 	r.dataListener.SubscribeURL(conf, zkListener)
-
+	r.WaitGroup().Add(1)
 	go r.listener.ListenServiceEvent(conf, fmt.Sprintf("/dubbo/%s/"+constant.DEFAULT_CATEGORY, url.QueryEscape(conf.Service())), r.dataListener)
 
 	return zkListener, nil
diff --git a/remoting/zookeeper/listener.go b/remoting/zookeeper/listener.go
index 5188ce8..1ffea88 100644
--- a/remoting/zookeeper/listener.go
+++ b/remoting/zookeeper/listener.go
@@ -77,13 +77,21 @@ func (l *ZkEventListener) ListenServiceNodeEvent(zkPath string, listener ...remo
 			case zk.EventNodeDataChanged:
 				logger.Warnf("zk.ExistW(key{%s}) = event{EventNodeDataChanged}", zkPath)
 				if len(listener) > 0 {
-					content, _, _ := l.client.Conn.Get(zkEvent.Path)
+					content, _, err := l.client.Conn.Get(zkEvent.Path)
+					if err != nil {
+						logger.Warnf("zk.Conn.Get{key:%s} = error{%v}", zkPath, err)
+						return false
+					}
 					listener[0].DataChange(remoting.Event{Path: zkEvent.Path, Action: remoting.EventTypeUpdate, Content: string(content)})
 				}
 			case zk.EventNodeCreated:
 				logger.Warnf("zk.ExistW(key{%s}) = event{EventNodeCreated}", zkPath)
 				if len(listener) > 0 {
-					content, _, _ := l.client.Conn.Get(zkEvent.Path)
+					content, _, err := l.client.Conn.Get(zkEvent.Path)
+					if err != nil {
+						logger.Warnf("zk.Conn.Get{key:%s} = error{%v}", zkPath, err)
+						return false
+					}
 					listener[0].DataChange(remoting.Event{Path: zkEvent.Path, Action: remoting.EventTypeAdd, Content: string(content)})
 				}
 			case zk.EventNotWatching: