Skip to content

Commit a7fda8f

Browse files
ejohnstownphilljj
authored andcommitted
Say what the disconnect contract covers
The contract in ssh.h claimed more than the code does. A CHANNEL_EOF already received outranks the drain, so both stream reads report WS_EOF with data still buffered, and wolfSSH_accept()/wolfSSH_connect() never look at the flag at all. Both fixes belong with the channel EOF work in #1195; until then the header says what is really gated. Issue: F-8837
1 parent 173a85b commit a7fda8f

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

wolfssh/internal.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,11 +1102,12 @@ struct WOLFSSH {
11021102
#endif
11031103
byte connReset;
11041104
byte isClosed;
1105-
/* Set when a DISCONNECT is sent or received. Gates every public send
1106-
* call, so nothing more goes out. Reads still hand back what arrived
1105+
/* Set when a DISCONNECT is sent or received. Gates the public send
1106+
* calls, so nothing more goes out. Reads still hand back what arrived
11071107
* before the disconnect; the head-of-list reads report it once their
1108-
* buffer runs dry. wolfSSH_worker() is not gated, the shutdown paths
1109-
* pump it. */
1108+
* buffer runs dry, unless a CHANNEL_EOF arrived first. wolfSSH_worker(),
1109+
* wolfSSH_accept() and wolfSSH_connect() are not gated; the shutdown
1110+
* paths pump the worker. */
11101111
byte disconnected;
11111112
/* Set once SendDisconnect() has bundled our own DISCONNECT into the
11121113
* output buffer, so a short send can still be flushed. The flag above

wolfssh/ssh.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,11 +559,14 @@ WOLFSSH_API int wolfSSH_accept(WOLFSSH* ssh);
559559
WOLFSSH_API int wolfSSH_connect(WOLFSSH* ssh);
560560
WOLFSSH_API int wolfSSH_shutdown(WOLFSSH* ssh);
561561
/* A disconnect, sent or received, ends the session. Nothing more goes out:
562-
* every send call in this header, above this comment and below it, reports
563-
* WS_DISCONNECT from then on. Reads are not gated, so channel data that
562+
* wolfSSH_shutdown() above this comment, and every send call below it,
563+
* report WS_DISCONNECT from then on. wolfSSH_accept() and
564+
* wolfSSH_connect() are not gated; do not drive the handshake after a
565+
* disconnect. Reads are not gated either, so channel data that
564566
* arrived before the disconnect can still be drained; wolfSSH_stream_read()
565567
* and wolfSSH_stream_peek() report WS_DISCONNECT once their buffer runs
566-
* dry. RFC 4253 section 11.1. */
568+
* dry. A CHANNEL_EOF already received outranks that drain: both report
569+
* WS_EOF with data possibly still buffered. RFC 4253 section 11.1. */
567570
WOLFSSH_API int wolfSSH_stream_peek(WOLFSSH* ssh, byte* buf, word32 bufSz);
568571
WOLFSSH_API int wolfSSH_stream_read(WOLFSSH* ssh, byte* buf, word32 bufSz);
569572
WOLFSSH_API int wolfSSH_stream_send(WOLFSSH* ssh, byte* buf, word32 bufSz);

0 commit comments

Comments
 (0)