diff --git a/examples/echoserver/echoserver.c b/examples/echoserver/echoserver.c index 482d184d..156ce308 100644 --- a/examples/echoserver/echoserver.c +++ b/examples/echoserver/echoserver.c @@ -1011,6 +1011,9 @@ static int ssh_worker(thread_ctx_t* threadCtx) channel. The additional channel is only used with the agent. */ cnt_r = wolfSSH_worker(ssh, &lastChannel); + /* Take the worker's status before the drain below: its + * reads and sends latch their own into ssh->error. */ + rc = wolfSSH_get_error(ssh); /* The peer is done sending: hand back the backlog and answer * its EOF, or a client that half-closed waits on a server @@ -1072,7 +1075,6 @@ static int ssh_worker(thread_ctx_t* threadCtx) } if (cnt_r < 0) { - rc = wolfSSH_get_error(ssh); /* wolfSSH_worker() reports WS_REKEYING in place of * WS_CHAN_RXD while a rekey is in flight, and the data * report is never raised again, so drain on both or the diff --git a/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/echoserver.c b/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/echoserver.c index 6baa1af0..179d02c5 100644 --- a/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/echoserver.c +++ b/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/echoserver.c @@ -995,6 +995,9 @@ static int ssh_worker(thread_ctx_t* threadCtx) channel. The additional channel is only used with the agent. */ cnt_r = wolfSSH_worker(ssh, &lastChannel); + /* Take the worker's status before the drain below: its + * reads and sends latch their own into ssh->error. */ + rc = wolfSSH_get_error(ssh); /* The peer is done sending: hand back the backlog and answer * its EOF, or a client that half-closed waits on a server @@ -1056,7 +1059,6 @@ static int ssh_worker(thread_ctx_t* threadCtx) } if (cnt_r < 0) { - rc = wolfSSH_get_error(ssh); if (rc == WS_CHAN_RXD) { if (lastChannel == shellChannelId) { cnt_r = wolfSSH_ChannelIdRead(ssh, shellChannelId,