From 0ac4a3d77199c3c975c2fe2b65284776a607b13d Mon Sep 17 00:00:00 2001 From: John Safranek Date: Mon, 3 Aug 2026 13:44:04 -0700 Subject: [PATCH] examples/client: drop dead select_ret tests in NonBlockSSH_connect The loop condition already guarantees a want-read or want-write error, so the select_ret arms of the retry test and the else chain could never run. Retry unconditionally; tcp_select still throttles the loop. Same change applied to the copy in apps/wolfssh/wolfssh.c. Issue: CID-572884 --- apps/wolfssh/wolfssh.c | 23 ++++++----------------- examples/client/client.c | 23 ++++++----------------- 2 files changed, 12 insertions(+), 34 deletions(-) diff --git a/apps/wolfssh/wolfssh.c b/apps/wolfssh/wolfssh.c index 4ae621e3..92901b70 100644 --- a/apps/wolfssh/wolfssh.c +++ b/apps/wolfssh/wolfssh.c @@ -119,7 +119,6 @@ static int NonBlockSSH_connect(WOLFSSH* ssh) int ret; int error; SOCKET_T sockfd; - int select_ret = 0; ret = wolfSSH_connect(ssh); error = wolfSSH_get_error(ssh); @@ -128,23 +127,13 @@ static int NonBlockSSH_connect(WOLFSSH* ssh) while (ret != WS_SUCCESS && (error == WS_WANT_READ || error == WS_WANT_WRITE)) { - select_ret = tcp_select(sockfd, 1); + /* tcp_select only throttles the loop, always retry. On want write + * there may be pending data to send, and on want read a test case + * may have forced the want read with no more data coming in. */ + (void)tcp_select(sockfd, 1); - /* Continue in want write cases even if did not select on socket - * because there could be pending data to be written. Added continue - * on want write for test cases where a forced want read was introduced - * and the socket will not be receiving more data. */ - if (error == WS_WANT_WRITE || error == WS_WANT_READ || - select_ret == WS_SELECT_RECV_READY || - select_ret == WS_SELECT_ERROR_READY) - { - ret = wolfSSH_connect(ssh); - error = wolfSSH_get_error(ssh); - } - else if (select_ret == WS_SELECT_TIMEOUT) - error = WS_WANT_READ; - else - error = WS_FATAL_ERROR; + ret = wolfSSH_connect(ssh); + error = wolfSSH_get_error(ssh); } return ret; diff --git a/examples/client/client.c b/examples/client/client.c index 61c79e93..c6114118 100644 --- a/examples/client/client.c +++ b/examples/client/client.c @@ -149,7 +149,6 @@ static int NonBlockSSH_connect(WOLFSSH* ssh) int ret; int error; SOCKET_T sockfd; - int select_ret = 0; ret = wolfSSH_connect(ssh); error = wolfSSH_get_error(ssh); @@ -163,23 +162,13 @@ static int NonBlockSSH_connect(WOLFSSH* ssh) else if (error == WS_WANT_WRITE) printf("... client would write block\n"); - select_ret = tcp_select(sockfd, 1); + /* tcp_select only throttles the loop, always retry. On want write + * there may be pending data to send, and on want read a test case + * may have forced the want read with no more data coming in. */ + (void)tcp_select(sockfd, 1); - /* Continue in want write cases even if did not select on socket - * because there could be pending data to be written. Added continue - * on want write for test cases where a forced want read was introduced - * and the socket will not be receiving more data. */ - if (error == WS_WANT_WRITE || error == WS_WANT_READ || - select_ret == WS_SELECT_RECV_READY || - select_ret == WS_SELECT_ERROR_READY) - { - ret = wolfSSH_connect(ssh); - error = wolfSSH_get_error(ssh); - } - else if (select_ret == WS_SELECT_TIMEOUT) - error = WS_WANT_READ; - else - error = WS_FATAL_ERROR; + ret = wolfSSH_connect(ssh); + error = wolfSSH_get_error(ssh); } return ret;