Merged
Conversation
…y termination of the main process before the coordination process executes wg.add(1).
Contributor
Author
复现在文件cmd/socks.go中的协程函数中增加睡眠延迟,如下 go func() {
time.Sleep(2 * 1000 * time.Millisecond) // 虚拟延迟
wg.Add(1)
defer wg.Done()
socks.Serve(lp, sp, key)
}()重新运行,没有任何输出就结束了。 go run main.go socks -l 10808 -s 10809 -h 192.168.1.123 |
Owner
|
感谢 |
power12317
pushed a commit
to power12317/SCFProxy
that referenced
this pull request
Jan 15, 2026
…alid 修复cmd/socks启动WaitGroup等待失败问题。
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.
问题
使用SCFProxy进行socks代理时,偶然发现,cmd/socks在执行时,主进程创建WaitGroup并启动一个协程后,可能发生主进程的wg.wait()比协程的wg.add(1)先执行的情况,造成协程跟随主进程提前结束的情况,协程后面的监听服务也未开始执行。
修复
将wg.add(1)放在协程外面wg.wait()前执行。