dubbo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [dubbo-go] zouyx commented on a change in pull request #578: Rft : Optimize lock for zookeeper registry
Date Mon, 01 Jun 2020 07:37:28 GMT

zouyx commented on a change in pull request #578:
URL: https://github.com/apache/dubbo-go/pull/578#discussion_r433082642



##########
File path: registry/zookeeper/registry.go
##########
@@ -156,12 +156,15 @@ func (r *zkRegistry) DoRegister(root string, node string) error {
 }
 
 func (r *zkRegistry) DoUnregister(root string, node string) error {
-	r.cltLock.Lock()
-	defer r.cltLock.Unlock()
-	if !r.ZkClient().ZkConnValid() {
+	client := r.client

Review comment:
       copy new var for operation

##########
File path: registry/zookeeper/registry.go
##########
@@ -252,9 +255,7 @@ func (r *zkRegistry) getListener(conf *common.URL) (*RegistryConfigurationListen
 
 	zkListener = NewRegistryConfigurationListener(r.client, r, conf)
 	if r.listener == nil {
-		r.cltLock.Lock()

Review comment:
        `client := r.client` is atomic

##########
File path: remoting/zookeeper/client.go
##########
@@ -468,9 +464,7 @@ func (z *ZookeeperClient) RegisterTemp(basePath string, node string) (string,
er
 	err = errNilZkClientConn
 	data = []byte("")
 	zkPath = path.Join(basePath) + "/" + node
-	z.Lock()
 	conn := z.Conn

Review comment:
       as above

##########
File path: remoting/zookeeper/client.go
##########
@@ -446,9 +444,7 @@ func (z *ZookeeperClient) Delete(basePath string) error {
 	)
 
 	err = errNilZkClientConn
-	z.Lock()
 	conn := z.Conn

Review comment:
       as above

##########
File path: remoting/zookeeper/client.go
##########
@@ -419,9 +419,7 @@ func (z *ZookeeperClient) CreateWithValue(basePath string, value []byte)
error {
 	for _, str := range strings.Split(basePath, "/")[1:] {
 		tmpPath = path.Join(tmpPath, "/", str)
 		err = errNilZkClientConn
-		z.Lock()
 		conn := z.Conn

Review comment:
        `conn := z.Conn` is atomic




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Mime
View raw message