Oxidaner commented on code in PR #3293:
URL: https://github.com/apache/dubbo-go/pull/3293#discussion_r3151380408
##########
server/server.go:
##########
@@ -326,6 +341,13 @@ func (s *Server) Serve() error {
// release lock in case causing deadlock
s.mu.Unlock()
+ defer func() {
+ s.mu.Lock()
+ s.serve = false
Review Comment:
我理解了您的意思但是我认为现在的解决方案并不存在该问题
1. 导出服务: `exported` 校验已经阻止了 `Export()` 重复执行
```go
func (svcOpts *ServiceOptions) Export() error {
info := svcOpts.info
svcConf := svcOpts.Service
// TODO: delay needExport
if svcOpts.unexported != nil && svcOpts.unexported.Load() {
err := perrors.Errorf("The service %v has already unexported!",
svcConf.Interface)
logger.Errorf(err.Error())
return err
}
if svcOpts.exported != nil && svcOpts.exported.Load() {
logger.Warnf("The service %v has already exported!",
svcConf.Interface)
return nil
}
```
2. 注册实例: `extension.GetProtocol(constant.RegistryKey)` 返回的是**同一个**
`registryProtocol` 单例 如果 `graceful shutdown` 的
`unregisterRegistries()`已经做了`UnRegister` 会返回nil 也不会产生**资源重复**
```go
protocol := extension.GetProtocol(constant.RegistryKey)
if rf, ok := protocol.(registry.RegistryFactory); ok {
for _, r := range rf.GetRegistries() {
if err := ctx.Err(); err != nil {
return err
}
if sdr, ok := r.(registry.ServiceDiscoveryRegistry); ok
{
if err := sdr.RegisterService(); err != nil {
return err
}
}
}
}
```
--
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]