Echoserver Channel Regrouping#962
Merged
padelsbach merged 1 commit intowolfSSL:masterfrom May 5, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the echoserver example’s channel/forwarding/agent state handling by consolidating per-feature state into a shared WS_AppCtx (with a unified WS_AppState), and updates the forwarding expect test to avoid deadlocks caused by verbose debug logging filling the PTY buffer.
Changes:
- Consolidate forwarding and agent state machines into
WS_AppState, and hoist shared fields intoWS_AppCtxwith per-feature “private” state hung offprivateData. - Update agent/fwd default action callbacks to accept a
WS_AppCtx*and fetch feature-specific state viaappCtx->privateData. - Make
scripts/fwd.test.expectmore robust under--enable-debugby redirecting output to files and syncing on portfwd’s-Rready file.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| scripts/fwd.test.expect | Redirects server/client output to log files and waits on a ready file instead of PTY output matching to prevent debug-log PTY stalls. |
| examples/echoserver/echoserver.c | Refactors example forwarding/agent/shell state into WS_AppCtx/WS_AppState and updates callbacks + worker loop to use the regrouped state. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
187a347 to
b0a10a2
Compare
Refactor of the echoserver example only; library is unchanged. 1. Collapse FwdStates and AGENT_STATE_* into a single WS_AppState (INIT/LISTEN/CONNECT/CONNECTED). FWD_STATE_DIRECT becomes an isDirect flag, cleared after connect. 2. Hoist the fields shared by the forwarding, agent, and shell paths into a common WS_AppCtx (privateData, listenFd, appFd, channelId, state, buffer). Shell only uses buffer. 3. Feature-specific remainder stays in WS_AgentCbActionCtx (name) and WS_FwdCbActionCtx (host/origin name+port, isDirect). Drop the unused pid field; inline getpid() at the call site. 4. wolfSSH_AGENT_DefaultActions and wolfSSH_FwdDefaultActions now take a WS_AppCtx* and reach feature-specific state via appCtx->privateData. echoserver_test() is updated to register the WS_AppCtx (not the old CbCtx) with wolfSSH_set_agent_cb_ctx and wolfSSH_SetFwdCbCtx. 5. Reindent ssh_worker()'s #ifdef blocks and add /* WOLFSSH_xxx */ markers. 6. fwd.test.expect: redirect echoserver and portfwd output to log files and sync on portfwd's -R ready file instead of matching "sampled" in the pty. Under --enable-debug the WLOG volume fills the pty and stalls portfwd in select() before channel-open.
b0a10a2 to
41c5e0f
Compare
padelsbach
approved these changes
May 5, 2026
Contributor
padelsbach
left a comment
There was a problem hiding this comment.
A couple minor suggestions, but looks good overall
JacobBarthelmeh
approved these changes
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor of the echoserver example only; library is unchanged.