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
pull/1140/head
John Safranek 2026-08-03 13:44:04 -07:00 committed by Ruby Martin
parent afb4d70c5f
commit 0ac4a3d771
2 changed files with 12 additions and 34 deletions

View File

@ -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;

View File

@ -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;