Skip to content
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

fix: concurrent map operations #150

Merged
merged 2 commits into from
Jan 4, 2025
Merged

fix: concurrent map operations #150

merged 2 commits into from
Jan 4, 2025

Conversation

uubulb
Copy link
Contributor

@uubulb uubulb commented Jan 4, 2025

No description provided.

@naiba
Copy link
Member

naiba commented Jan 4, 2025

if !updateTempStatus.CompareAndSwap(false, true) {
return
}
defer updateTempStatus.Store(false)

这个可以去掉了

@uubulb
Copy link
Contributor Author

uubulb commented Jan 4, 2025

if !updateTempStatus.CompareAndSwap(false, true) { return } defer updateTempStatus.Store(false)

这个可以去掉了

当时加这个应该是想一次只跑一个,这个操作比较慢 可能会同时多个 goroutine 积压在一起

@naiba
Copy link
Member

naiba commented Jan 4, 2025 via email

@uubulb
Copy link
Contributor Author

uubulb commented Jan 4, 2025

看你commit信息是修复可能的数据竞争

应该跟那个不一样,那个是为了防止任务 goroutine 执行的 reportHost 与 reportState 的冲突,不过现在删了的话应该没必要了

@@ -55,7 +55,7 @@ func FetchIP(useIPv6CountryCode bool) *pb.GeoIP {
if ipv6 != "" && (useIPv6CountryCode || ipv4 == "") {
GeoQueryIPChanged = GeoQueryIP != ipv6 || GeoQueryIPChanged
GeoQueryIP = ipv6
} else {
} else if ipv4 != "" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样不会用到连接ip了

Copy link
Contributor Author

@uubulb uubulb Jan 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果自启动来就一直是空应该可以取到

@naiba
Copy link
Member

naiba commented Jan 4, 2025

看你commit信息是修复可能的数据竞争

应该跟那个不一样,那个是为了防止任务 goroutine 执行的 reporthost 与主线程的冲突,不过现在删了的话应该没必要了

这样会不会出现 40 -> 0 -> 40 -> 0 反复横跳

@naiba naiba merged commit 5ade46c into nezhahq:main Jan 4, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants