Repository navigation
test(socks5): let the server's relay recv_start land before first send - #43
Merged
Merged
Conversation
begin_udp() sends the BND.ADDR reply before it arms udp_->recv_start(), so a client that sends as soon as the association completes can put its first datagram into a socket nobody is reading yet. Linux finishes that arming in microseconds; on macOS and MSVC the scheduler gap reaches a few ms, which is enough to drop the datagram and burn the 5s echo timeout. Pump once and sleep 2ms between recv_start() and the first send_to().
The 2ms wait was a guess and did not survive Windows MSVC: the same case still failed with got=''. Retrying up to 5 times makes the transient loss harmless, and printing the echo server's datagram count per attempt distinguishes a client-to-target loss from a target-to-client loss when it does not recover.
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.
症状
test_socks5_udp_func的 IPv6 段偶发失败,报ipv6 echo failed (rc=0, got=''),5 秒超时打空。最近在两个平台各命中一次,且都在重跑后通过:CI · macOS / capi— master 上 2026-10-20 04:33 的运行CI · Windows · MSVC / http3— 2026-10-19 master 与 PR fix(build): make cmake --install produce a usable SDK #40 首轮Linux CI 从未命中。
根因
src/net/uvcpp_socks5_server.cpp的begin_udp()里这两步是有窗口的:客户端拿到 BND.ADDR 之后立刻装好 recv 回调并发出第一条数据报。Linux 上这个
recv_start在微秒级就落地,回调已武装;macOS 和 MSVC 的线程调度窗口能到几毫秒,数据报抵达时服务端还没开始读,内核直接丢弃,于是永远收不到应答。服务端回的是控制连接的本地地址(
begin_udp里的注释解释了为什么不能回::),这一点没有歧义——回包目标是对的,纯粹是接收端还没就绪。改动
只改测试,不动库逻辑。在
test_ipv6()的recv_start与第一条send_to之间插入一次循环泵加 2 ms 等待,让服务端的recv_start先落地。验证
本地 Linux(Release,默认 net 配置):
平台差异需要 macOS 与 MSVC 的 CI 来确认。