Merge pull request #289 from JacobBarthelmeh/interop

add peek when waiting for data
pull/290/head
John Safranek 2020-10-01 12:05:06 -07:00 committed by GitHub
commit 06ea6eb2d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
*/
static int sftp_worker(thread_ctx_t* threadCtx) {
byte tmp[1];
int ret = WS_SUCCESS;
int error = WS_SUCCESS;
SOCKET_T sockfd;
@ -910,7 +911,13 @@ static int sftp_worker(thread_ctx_t* threadCtx) {
printf("... sftp server would write block\n");
}
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 ||
select_ret == WS_SELECT_ERROR_READY ||
error == WS_WANT_WRITE)