Alanxtl commented on code in PR #3108:
URL: https://github.com/apache/dubbo-go/pull/3108#discussion_r2618494407
##########
registry/servicediscovery/service_discovery_registry.go:
##########
@@ -133,14 +137,31 @@ func createInstance(meta *info.MetadataInfo, url
*common.URL) registry.ServiceIn
}
func (s *serviceDiscoveryRegistry) UnRegisterService() error {
- return s.serviceDiscovery.Unregister(s.instance)
+ s.lock.Lock()
+ defer s.lock.Unlock()
Review Comment:
done, 我改成了这样:
```go
func (s *serviceDiscoveryRegistry) UnRegisterService() error {
s.lock.Lock()
keep := s.instances[:0]
origin := s.instances[:]
s.lock.Unlock()
var errs []error
for _, v := range origin {
if err := s.serviceDiscovery.Unregister(v); err != nil {
// fail to unregister
keep = append(keep, v)
errs = append(errs, err)
}
}
s.lock.Lock()
s.instances = keep
s.lock.Unlock()
return errors.Join(errs...)
}
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]