Repository navigation
pingpong: schedule server response timeouts for the socket API - #23246
KurodaKayn wants to merge 2 commits into
Conversation
The nonblocking pingpong state machine checks the response deadline without scheduling a timer. A silent server can therefore leave curl_multi_socket_action() waiting indefinitely. Register the remaining time with a dedicated expiration ID so the event loop wakes up to check the response deadline. Add regression tests for FTP, IMAP, POP3 and SMTP using the existing event-driven client with an independent test deadline. Fixes curl#23025
vszakats
left a comment
There was a problem hiding this comment.
Is there a strong reason to test this in 4 individual test? Could they perhaps be merged into a single test or perhaps tested with one selected protocol only? (They seem to be all using the same lower-level fix)
I originally added one for each protocol because the issue report covered FTP, IMAP, POP3, SMTP, and I verified the reproducer with all four. I agree that one representative protocol test is sufficient for the regression. I will keep the FTP case and remove the other three |
The FTP, IMAP, POP3 and SMTP cases all exercise the same pingpong\nstate machine and timer path. Keep one representative protocol case to\ncover the regression without duplicating identical tests. Follow-up to 596f663
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The shared four-protocol timeout change lacks the reported regression coverage beyond FTP.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Schedules pingpong response deadlines so socket-driven transfers can time out when servers remain silent, addressing #23025.
Changes:
- Adds a dedicated server-response timer and trace name.
- Extends the event-driven test client with configurable deadlines.
- Adds an FTP regression test and runner support.
| File | Description |
|---|---|
| tests/runner.pm | Routes cli_ tools through libtests. |
| tests/libtest/cli_ev_download.c | Adds timeout options and deadline cleanup. |
| tests/data/test2330 | Tests FTP response timeouts. |
| tests/data/Makefile.am | Registers test2330. |
| lib/urldata.h | Defines the response timer identifier. |
| lib/pingpong.c | Schedules nonblocking response deadlines. |
| lib/curl_trc.c | Names the timer in traces. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Thanks! |
|
Seeing the test added by this PR failing in torture tests without c-ares on Linux and with threaded-resolver on macOS. Meaning this test fails torture with default build settings: macOS: https://github.com/curl/curl/actions/runs/42739522174/job/129576860210?pr=23869#step:17:1457 → PR #23872 |
Seen in test 2330 torture with c-ares not enabled, or threaded-resolved not disabled. Fixing: ``` test 2330 [FTP server response timeout with the socket action API] 76 functions found, but only fail 25 (32.89%) ** MEMORY FAILURE Leak detected: memory still allocated: 3056 bytes At 5c4ca478c9e8, there is 3056 bytes. allocated by /home/runner/work/curl/curl/lib/url.c:457 LIMIT /home/runner/work/curl/curl/lib/curlx/strdup.c:87 malloc reached memlimit 2330: torture FAILED: function number 14 in test. invoke with "-t14" to repeat this single case. ``` Linux: https://github.com/curl/curl/actions/runs/42739521997/job/129576860241?pr=23869#step:45:3215 macOS: https://github.com/curl/curl/actions/runs/42739522174/job/129576860210?pr=23869#step:17:1457 Bug: #23246 (comment) Bug: #23869 (comment) Follow-up to b32baab #23246 Follow-up to 820c014 #22304 Cherry-picked from #23869 Closes #23872
Thanks for catching this and fixing the error-path |

A silent FTP, IMAP, POP3 or SMTP server can leave transfers driven by
curl_multi_socket_action() waiting past CURLOPT_SERVER_RESPONSE_TIMEOUT_MS
because the response deadline is checked but never scheduled.
Register the remaining response time with a dedicated timer in the
nonblocking pingpong state machine.
Add a representative FTP regression test (2330) using the existing
event-driven client. It sets a 1-second response timeout and a separate
3-second test deadline that does not drive libcurl's timers. The test
fails before the fix and passes afterward. IMAP, POP3 and SMTP share
the same nonblocking pingpong path.
Validation on macOS with a Debug build and TLS disabled:
1 second for all four protocols.
Fixes #23025