You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/08/05 13:34:46 UTC

[GitHub] [pulsar-client-go] cckellogg commented on a change in pull request #581: Fix data race issue in ServiceNameResolver

cckellogg commented on a change in pull request #581:
URL: https://github.com/apache/pulsar-client-go/pull/581#discussion_r683457449



##########
File path: pulsar/internal/service_name_resolver.go
##########
@@ -63,6 +66,8 @@ func (r *pulsarServiceNameResolver) ResolveHost() (*url.URL, error) {
 	if len(r.AddressList) == 1 {
 		return r.AddressList[0], nil
 	}
+	r.mutex.Lock()
+	defer r.mutex.Unlock()

Review comment:
       If we are using a mutex now there is no need for the atomic store. Same for the code below.

##########
File path: pulsar/internal/service_name_resolver.go
##########
@@ -99,6 +104,8 @@ func (r *pulsarServiceNameResolver) UpdateServiceURL(u *url.URL) error {
 	r.ServiceURL = u
 	r.ServiceURI = uri
 	rand.Seed(time.Now().Unix()) // initialize global pseudo random generator

Review comment:
       This is kind of outside of the change but this should be done in the init function.




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

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