add peek when waiting for data

pull/289/head
Jacob Barthelmeh 2020-09-30 13:22:07 -06:00
parent 0b1e0345c4
commit 000b8544c6
1 changed files with 8 additions and 1 deletions

View File

@ -896,6 +896,7 @@ static int shell_worker(thread_ctx_t* threadCtx)
* returns 0 on success * returns 0 on success
*/ */
static int sftp_worker(thread_ctx_t* threadCtx) { static int sftp_worker(thread_ctx_t* threadCtx) {
byte tmp[1];
int ret = WS_SUCCESS; int ret = WS_SUCCESS;
int error = WS_SUCCESS; int error = WS_SUCCESS;
SOCKET_T sockfd; SOCKET_T sockfd;
@ -910,7 +911,13 @@ static int sftp_worker(thread_ctx_t* threadCtx) {
printf("... sftp server would write block\n"); printf("... sftp server would write block\n");
} }
select_ret = tcp_select(sockfd, TEST_SFTP_TIMEOUT); if (wolfSSH_stream_peek(threadCtx->ssh, tmp, 1) > 0) {
select_ret = WS_SELECT_RECV_READY;
}
else {
select_ret = tcp_select(sockfd, TEST_SFTP_TIMEOUT);
}
if (select_ret == WS_SELECT_RECV_READY || if (select_ret == WS_SELECT_RECV_READY ||
select_ret == WS_SELECT_ERROR_READY || select_ret == WS_SELECT_ERROR_READY ||
error == WS_WANT_WRITE) error == WS_WANT_WRITE)