jieguo-coder commented on code in PR #3367:
URL: https://github.com/apache/dubbo-go/pull/3367#discussion_r3407738748
##########
metadata/metadata.go:
##########
@@ -34,27 +39,37 @@ func GetMetadataService() MetadataService {
}
func GetMetadataInfo(registryId string) *info.MetadataInfo {
+ registryMetadataLock.RLock()
+ defer registryMetadataLock.RUnlock()
return registryMetadataInfo[registryId]
}
func AddService(registryId string, url *common.URL) {
+ registryMetadataLock.Lock()
Review Comment:
我已经更新了 `metadata/metadata.go` 中的 `RemoveService` 和
`RemoveSubscribeURL`。现在,它们会获取
`registryMetadataLock.RLock()`,执行映射查找,并在调用实例自身的方法之前立即释放 `RUnlock()`
>
全局锁粒度最小化,并与 `AddService` 完全对称,在不引入任何死锁的情况下解决并发读写风险
--
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]