diff --git a/examples/echoserver/echoserver.c b/examples/echoserver/echoserver.c index d3ba00eb..4d262851 100644 --- a/examples/echoserver/echoserver.c +++ b/examples/echoserver/echoserver.c @@ -1222,6 +1222,9 @@ static int ssh_worker(thread_ctx_t* threadCtx) } #endif + if (wolfSSH_OutputPending(ssh)) + wantWrite = 1; + FD_ZERO(&writeFds); if (wantWrite) FD_SET(sshFd, &writeFds); @@ -1297,9 +1300,15 @@ static int ssh_worker(thread_ctx_t* threadCtx) break; } #endif - /* The channel reads below overwrite cnt_r with a byte - * count, so keep the worker's status. */ + /* rc keeps the worker's status: cnt_r and ssh->error are + * both reused. */ rc = cnt_r; + if (rc == WS_FATAL_ERROR) { + int err = wolfSSH_get_error(ssh); + + if (err == WS_WANT_READ || err == WS_WANT_WRITE) + rc = err; + } /* The peer is done sending: hand back the backlog and answer * its EOF, since the library no longer answers for us. Off @@ -1515,9 +1524,7 @@ static int ssh_worker(thread_ctx_t* threadCtx) wantWrite = 1; continue; } - else if (rc != WS_FATAL_ERROR - || (wolfSSH_get_error(ssh) != WS_WANT_READ - && wolfSSH_get_error(ssh) != WS_WANT_WRITE)) { + else if (rc != WS_WANT_READ) { #ifdef SHELL_DEBUG printf("Break:read sshFd returns %d: errno =%x\n", cnt_r, errno); 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 c8c1fdb7..3f6f708a 100644 --- a/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/echoserver.c +++ b/ide/Espressif/ESP-IDF/examples/wolfssh_echoserver/main/echoserver.c @@ -995,9 +995,15 @@ static int ssh_worker(thread_ctx_t* threadCtx) channel. The additional channel is only used with the agent. */ cnt_r = wolfSSH_worker(ssh, &lastChannel); - /* The channel reads below overwrite cnt_r with a byte - * count, so keep the worker's status. */ + /* rc keeps the worker's status: cnt_r and ssh->error are + * both reused. */ rc = cnt_r; + if (rc == WS_FATAL_ERROR) { + int err = wolfSSH_get_error(ssh); + + if (err == WS_WANT_READ || err == WS_WANT_WRITE) + rc = err; + } /* The peer is done sending: hand back the backlog and answer * its EOF, since the library no longer answers for us. Off @@ -1167,12 +1173,7 @@ static int ssh_worker(thread_ctx_t* threadCtx) * above, which has already run this pass. */ continue; } - else if (rc == WS_WANT_WRITE) { - /* Transient; the queue drives the write side. */ - } - else if (rc != WS_FATAL_ERROR - || (wolfSSH_get_error(ssh) != WS_WANT_READ - && wolfSSH_get_error(ssh) != WS_WANT_WRITE)) { + else if (rc != WS_WANT_READ && rc != WS_WANT_WRITE) { #ifdef SHELL_DEBUG printf("Break:read sshFd returns %d: errno =%x\n", cnt_r, errno); diff --git a/scripts/fwd-bulk.test b/scripts/fwd-bulk.test index 4004329c..b327c38c 100755 --- a/scripts/fwd-bulk.test +++ b/scripts/fwd-bulk.test @@ -80,15 +80,13 @@ stall_limit=15 ./examples/portfwd/portfwd '-?' 2>&1 | grep -q "does not exist" \ && { echo "forwarding not compiled in, skipping"; exit 77; } -# A WOLFSSH_TEST_BLOCK build fails writes at random, which stalls the -# echoserver regardless of what the peer does. The other echoserver scripts -# skip it for the same reason. WOLFSSH_OPTIONS=`./apps/wolfssh-options` || { echo "fail: could not run ./apps/wolfssh-options" exit 1 } echo "$WOLFSSH_OPTIONS" | grep -qx "TEST_BLOCK" \ - && { echo "macro WOLFSSH_TEST_BLOCK was used, skipping"; exit 77; } + && { echo "portfwd does not support non-blocking mode, skipping test" + exit 77; } do_cleanup() { for pid in $nc_client_pid $portfwd_pid $server_pid $nc_server_pid \ diff --git a/scripts/sshclient.test b/scripts/sshclient.test index 762f457f..4e8c2684 100755 --- a/scripts/sshclient.test +++ b/scripts/sshclient.test @@ -30,14 +30,10 @@ client_limit=60 ./examples/echoserver/echoserver '-?' 2>&1 | grep -q "^echoserver " \ || { echo "echoserver doesn't run, skipping"; exit 77; } -# A WOLFSSH_TEST_BLOCK build fails writes at random. The echoserver leaves a -# failed write queued and then waits on the peer for a reply to the message -# it never sent, so a session stalls no matter what the client does. The -# other echoserver scripts skip this build for the same reason. if [ -x ./examples/client/client ] \ && ./examples/client/client -h 2>&1 | grep -q "WOLFSSH_TEST_BLOCK" then - echo "macro WOLFSSH_TEST_BLOCK was used, skipping" + echo "wolfssh client does not support non-blocking mode, skipping test" exit 77 fi