Skip to content

connect: do not busy-loop in blocking connect without a timeout - #23024

Closed
aeroyorch wants to merge 1 commit into
curl:masterfrom
aeroyorch:connect-busy-loop-no-timeout
Closed

aeroyorch wants to merge 1 commit into
curl:masterfrom
aeroyorch:connect-busy-loop-no-timeout

Conversation

@aeroyorch

Copy link
Copy Markdown
Contributor

Similar to #23005 but now with connect: avoid busy loop in the blocking Curl_conn_connect() when Curl_timeleft_ms() returns 0 (i.e. no timeout).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused change correctly handles the no-timeout case without altering configured timeout behavior.

Review effort: Balanced
Findings: None

What changed in this PR

Prevents CPU busy-looping during blocking connections when no timeout is configured.

Changes:

  • Uses a 1-second polling interval when Curl_timeleft_ms() returns zero.
  • Preserves existing shorter polling limits.
File Description
lib/​connect.c Adds a finite fallback timeout for blocking connection polling.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@aeroyorch
aeroyorch force-pushed the connect-busy-loop-no-timeout branch from e9874f5 to e885c22 Compare October 3, 2026 07:59

@icing icing left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

@jay

jay commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

This is blocking code isn't it supposed to block in poll if there's no timeout set? (nevermind i see it's still blocking just preventing a busy loop. got it.)

@jay jay closed this in 6c74687 Oct 7, 2026
@jay

jay commented Oct 7, 2026

Copy link
Copy Markdown
Member

Thanks

@aeroyorch
aeroyorch deleted the connect-busy-loop-no-timeout branch October 7, 2026 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants