Skip to content

ssh: flush any queued output at teardown - #1219

Open
ejohnstown wants to merge 1 commit into
wolfSSL:masterfrom
ejohnstown:shutdown-flush
Open

ssh: flush any queued output at teardown#1219
ejohnstown wants to merge 1 commit into
wolfSSL:masterfrom
ejohnstown:shutdown-flush

Conversation

@ejohnstown

Copy link
Copy Markdown
Contributor

wolfSSH_shutdown() flushes whatever a short send left in the output buffer,
not just a queued disconnect. A rejected auth's USERAUTH_FAILURE has no
channel, and a channel close is retired the moment it is bundled, so neither
had anything left to carry the retry.

  • The gate still refuses a flush once the peer has disconnected, unless our
    own disconnect is the thing queued.
  • Tests cover the rejected auth with no channel, the close whose channel was
    already retired, and a flush that short-sends on a live channel.

wolfSSH_shutdown() flushes whatever a short send left in the output
buffer, not just a queued disconnect. A rejected auth's
USERAUTH_FAILURE has no channel, and DoChannelClose() retires the
channel as soon as the close is bundled, so neither had anything
left to carry the retry.

- The gate still refuses a flush once the peer has disconnected,
  unless our own disconnect is the thing queued.
- ssh.h documents the widened flush and the WS_WANT_WRITE a short
  one leaves wolfSSH_shutdown() returning.
- Tests cover the rejected auth with no channel and the close whose
  channel DoChannelClose() already retired.
- A flush that short-sends on a live channel leaves the teardown
  queued behind it, and the retry adds no second EOF or close.
Copilot AI lite review requested due to automatic review settings September 1, 2026 04:01

Copilot AI 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.

Pull request overview

Updates wolfSSH_shutdown() teardown behavior so it will flush any already-queued outbound bytes left behind by a short send (not only a queued local disconnect), while still preventing post-disconnect traffic unless the only queued output is the local disconnect.

Changes:

  • Generalize the shutdown-time “flush queued disconnect” gate into a “flush queued output” gate, with special-casing to suppress non-disconnect output after the peer has disconnected.
  • Extend regression coverage for queued output flush scenarios: rejected auth with no channel, channel-close queued after channel retirement, and a live-channel short-send during shutdown.
  • Document the broader shutdown flush behavior in the public header.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/ssh.c Generalizes queued-output flushing at teardown and in the post-disconnect send path.
wolfssh/ssh.h Expands wolfSSH_shutdown() API comment to describe the broader flush semantics and retry behavior.
tests/regress.c Adds regression tests covering newly supported queued-output flush scenarios and short-send retry behavior.

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants