Skip to content

vssh: do not busy-loop in blocking state machine without a timeout - #23005

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

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

Conversation

@aeroyorch

Copy link
Copy Markdown
Contributor

Avoid busy loop in SSH state machines (both libssh and libssh2) when Curl_timeleft_ms() returns 0 (i.e. no timeout).

@bagder

bagder commented Sep 19, 2026

Copy link
Copy Markdown
Member

Ideally of course we should not use these blocking functions at all, but while we do I think this is a correct fix.

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

Both SSH backends correctly avoid zero-timeout polling without affecting finite timeout behavior.

Review effort: Lite
Findings: None

What changed in this PR

Prevents libssh and libssh2 blocking state machines from busy-looping when no transfer timeout is configured.

Changes:

  • Uses a 1-second wait when Curl_timeleft_ms() returns zero.
  • Preserves existing timeout capping behavior.
File Description
lib/​vssh/​libssh2.c Fixes socket wait timeout handling.
lib/​vssh/​libssh.c Fixes readable-socket wait timeout handling.

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

@aeroyorch

Copy link
Copy Markdown
Contributor Author

Ideally of course we should not use these blocking functions at all, but while we do I think this is a correct fix.

Indeed. I ran into this while using the multi interface with async python wrapper for SFTP transfers and realized the SFTP paths still block. Is anyone working on making them non-blocking? If not, I'd be happy to contribute.

@aeroyorch
aeroyorch force-pushed the vssh-busy-loop-no-timeout branch from 7832d2e to 97f8d4b Compare September 19, 2026 18:18
@bagder

bagder commented Sep 20, 2026

Copy link
Copy Markdown
Member

Is anyone working on making them non-blocking? If not, I'd be happy to contribute.

I'm not aware of anyone working on these, no.

@bagder bagder closed this in 39088cd Sep 20, 2026
@bagder

bagder commented Sep 20, 2026

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants