Skip to content

conncache: poll an idle connection for pending input on every reuse (backport) - #62

Open
fadedreamz wants to merge 1 commit into
masterfrom
fix/conncache-poll-input-on-reuse
Open

fadedreamz wants to merge 1 commit into
masterfrom
fix/conncache-poll-input-on-reuse

Conversation

@fadedreamz

Copy link
Copy Markdown

Backport of upstream curl/curl@ef6b17cf12 (curl#23412). It's on upstream master after 8.23.0 and will first ship in 8.24.0.

Problem

curl 8.22.0 (upstream 2f1e94e) skips the connection alive check if it ran less than a second ago. Returning a connection to the pool counts as a check. So an idle HTTP/1.1 connection the server has closed is handed out as healthy within that second:

  1. The request goes out on the dead connection and gets nothing back.
  2. curl retries on a fresh connection (Curl_retry_request) and must rewind the upload.
  3. For a streaming upload whose read callback already returned CURL_READFUNC_PAUSE and has no seek support, the rewind fails with CURLE_SEND_FAIL_REWIND ("seek callback returned error 2").

In Unity this breaks HttpHandlerBehaviors.SendAsync_{Get,Put}WithLateWrittenBody_ServerReceivesFullBody on iOS. They pass with curl 8.20 (Yamato 77970446) and fail with 8.22 (Yamato 77880251).

Change

Poll for pending input on every reuse of an idle, non-multiplexed connection, as 8.20 did. The once-a-second limit stays for multiplexed connections and protocols with their own connection_is_dead.

Adapted to 8.22.0: upstream's cpool_conn_can_be_closed(conn) is spelled out as !CONN_INUSE(conn) && !conn->bits.connect_only. Upstream test 1701 is included.

Verification

  • Not built or run locally.
  • To verify: build through the libcurl submodule bump, then re-run the iOS PlayMode CoreTests job on unity/unity PR #130795.

🤖 Generated with Claude Code

Backport of upstream ef6b17c (curl#23412), adapted to 8.22.0:
upstream's cpool_conn_can_be_closed() is spelled out as
!CONN_INUSE(conn) && !conn->bits.connect_only.

Since 2f1e94e the alive check is skipped when it ran less than a
second ago, which also skipped the pending input check. An idle HTTP/1.1
connection closed by the server was then reused within that second; the
request failed, curl retried on a fresh connection and had to rewind the
upload, which fails for a paused, non-seekable streaming upload
(CURLE_SEND_FAIL_REWIND). Poll for pending input on every reuse of an
idle non-multiplexed connection, as 8.20 did.

(cherry picked from commit ef6b17c)
@github-actions github-actions Bot added the tests label Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant