-
Notifications
You must be signed in to change notification settings - Fork 995
fix: close #3247 config/protocol shared-state races #3271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
68f0a38
6fb9abe
8af236d
76e86f2
3553033
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,7 +133,7 @@ func (cc *ConsumerConfig) Load() { | |
| // use interface name defined by pb | ||
| refConfig.InterfaceName = triplePBService.XXX_InterfaceName() | ||
| } | ||
| if err := refConfig.Init(rootConfig); err != nil { | ||
| if err := refConfig.Init(GetRootConfig()); err != nil { | ||
| logger.Errorf(fmt.Sprintf("reference with registeredTypeName = %s init failed! err: %#v", registeredTypeName, err)) | ||
| continue | ||
| } | ||
|
|
@@ -185,7 +185,13 @@ func (cc *ConsumerConfig) Load() { | |
|
|
||
| // SetConsumerConfig sets consumerConfig by @c | ||
| func SetConsumerConfig(c ConsumerConfig) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SetConsumerConfig 里的 nil 分支在 rc == nil 时会丢失其他字段。如果 GetRootConfig() 还没被调用过(返回 nil),这里直接 SetRootConfig(RootConfig{Consumer: &c}) 会创建一个只有 Consumer 的 RootConfig,之前通过 Load() 设置的 Protocol、Application 等字段全部丢失。 建议:如果 GetRootConfig() 返回 nil,直接用 NewRootConfigBuilder() 构建一个默认值,再设置 Consumer: rc := GetRootConfig()
if rc == nil {
rc = NewRootConfigBuilder().Build()
}
next := *rc
next.Consumer = &c
SetRootConfig(next)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 感谢,我将尽快修复
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| rootConfig.Consumer = &c | ||
| rc := GetRootConfig() | ||
| if rc == nil { | ||
| rc = NewRootConfigBuilder().Build() | ||
| } | ||
| next := *rc | ||
| next.Consumer = &c | ||
| SetRootConfig(next) | ||
| } | ||
|
|
||
| func newEmptyConsumerConfig() *ConsumerConfig { | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个函数有啥用啊 返回的又不是深拷贝
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
确实,感谢,我现在去去掉这个加锁的逻辑
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.