Repository navigation
Conversation
The blocking client only installed SO_RCVTIMEO/SO_SNDTIMEO under _WIN32, so Linux and macOS ignored every timeout passed to connect_wait/send_wait and the blocking TLS handshake could wait forever. Install the timeouts on both platforms, map EAGAIN/EWOULDBLOCK to UV_ETIMEDOUT, and stop treating a read error (or a TLS WANT after the timeout) as a clean EOF, which used to deliver a truncated response as 200 OK.
Antruly
added a commit
that referenced
this pull request
Oct 19, 2026
- `CMakeLists.txt` 在 install 段前插入 61 行、pkg-config 段前再插入 6 行, 被引区间整体 +61/+67;`uvcpp_http_client.cpp` 的助手与新读循环让它后段 +8/+20/+91/+148;`uvcpp_http_client.h` 的两处参数说明 +2。 按 check_doc_lines.py --update 的 [移] 报告逐条改文档正文后刷新锁。 - `doc/web-http-guide.md`「三个容易写错的地方」第三节/第四节原本描述的是 修复前的行为(timeout 仅 Windows、失败交默认 200 OK),改写为现在的语义 (两个平台都设、每次 I/O 超时、失败返回 NONE 与负错误码)。 - 同页两处裸/歧义引用人工定到正确目标:`set_keep_alive` 声明改指 `uvcpp_http_client.h:242`;`doc/http2-status.md` 的 `set_http2_enabled` 声明改指 `.h:307`;`RELEASE.md` 的 `CMakeLists.txt:3099-3518` 随插入 改为 `3099-3579`。
Owner
Author
|
Content merged via #40. Closing to avoid duplicate merges. |
9 of 10 tasks
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.
问题
connect_wait()/send_wait()/send_wait_ssl()的timeout_ms在 Linux/macOS 上被静默忽略:do_ssl_handshake()无限阻塞。根因有四处:
send_wait_ssl()/send_wait_plain()里设置SO_RCVTIMEO/SO_SNDTIMEO的代码整段包在#ifdef _WIN32里。注释说 POSIX 没有等价写法,但这两个选项在 Linux 和 macOS 上都可用。read_one_message()把读取返回的n <= 0一律当 EOF,超时会被交付成半条响应。uvcpp_ssl::read()用0同时表示close_notify和WANT_READ,同步路径无法区分正常关闭和超时。for (i < 4)的紧循环重试;在阻塞 socket 上每次重试都会再等满一个timeout_ms,把 3 秒超时放大成 12 秒。uvcpp_http_response保留默认的200 OK,调用方日志会出现“请求失败,但状态码 200”。修改
EAGAIN/EWOULDBLOCK/ETIMEDOUT映射为UV_ETIMEDOUT。read_one_message()返回负的 libuv 错误码,不再把读错误当 EOF。last_ssl_error() == SSL_ERROR_ZERO_RETURN区分正常关闭;阻塞 socket 上的WANT_*按超时处理。resp.status_code复位为HTTP_STATUS_NONE。复现与验证(Linux x64)
服务端收下请求后静默 4 秒,客户端
timeout_ms = 1000:修复前:
修复后:
服务端只 accept、不做 TLS 握手,客户端
connect_wait(..., 3000):正常 TLS 响应仍返回
rc=0 status=200。残留
SO_RCVTIMEO是每次 I/O 的超时,不是整次请求的总 deadline;对端每隔略小于timeout_ms发一个字节仍可拖长请求。后续可以换成单调时钟 deadline +poll(),不阻塞本 PR。兼容性
-1变为具体的 libuv 错误码。status_code从默认的 200 变为 0。