fix: race condition of tcpConcurrent in dialer#2556
Merged
wwqgtxx merged 1 commit intoMetaCubeX:Alphafrom Feb 5, 2026
Merged
Conversation
Collaborator
|
我们暂时不打算合并该新功能,但是您可以只保留该PR中修复race的部分并提交 |
Collaborator
|
此外,请关闭对PR自动使用copilot的设置,否则您有可能会被block |
Author
|
已经进行了调整。 想问一下这个需求有没有替代方案?或者应该以什么形式实现? |
Collaborator
|
或许未来我们会为 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
这个 PR 为使用 Dialer Proxy 的 Proxy 提供了一个选项proxy-server-local-resolve,能让server为域名的 Proxy 能在本地解析域名。这个选项对于 Proxy 的域名解析经常变动,而 Dialer Proxy 的 DNS 缓存 TTL 无法控制的情况非常有用。代码直接复用了dialer.go的逻辑,尽可能减少了修改面。同时,在浏览相关代码的时候,发现了一个可能发生的竞态条件:
tcpConcurrent的调整会导致actualXXXStackDialContext的写入操作,这部分是受到dialMux保护的;但是对actualXXXStackDialContext的读取并没有被dialMux保护。这个 PR 将tcpConcurrent改为原子量,在避免严重影响性能的前提下修复了这个竞态问题。