Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions examples/echoserver/echoserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,14 @@
#define SOCKET_ECONNRESET ECONNRESET
#define SOCKET_ECONNABORTED ECONNABORTED
#define SOCKET_EWOULDBLOCK EWOULDBLOCK
#define SOCKET_EINTR EINTR
#else
#include <WS2tcpip.h>
#define SOCKET_ERRNO WSAGetLastError()
#define SOCKET_ECONNRESET WSAECONNRESET
#define SOCKET_ECONNABORTED WSAECONNABORTED
#define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK
#define SOCKET_EINTR WSAEINTR
#endif

#ifdef WOLFSSH_WINDOWS_CERT_STORE
Expand Down Expand Up @@ -1567,6 +1569,16 @@ static int sftp_worker(thread_ctx_t* threadCtx)
error == WS_WINDOW_FULL)
ret = error;
if (error == WS_WANT_WRITE || wolfSSH_SFTP_PendingSend(ssh)) {
/* The tcp_select() this skips watches reads only. */
if (error == WS_WANT_WRITE) {
selected = tcp_select_write(s, TEST_SFTP_TIMEOUT);
/* An interrupted select() is not a dead socket. */
if (selected == WS_SELECT_ERROR_READY
|| (selected == WS_SELECT_FAIL
&& SOCKET_ERRNO != SOCKET_EINTR)) {
break;
}
}
continue; /* no need to spend time attempting to pull data
* if there is still pending sends */
}
Comment thread
ejohnstown marked this conversation as resolved.
Expand Down
12 changes: 5 additions & 7 deletions src/wolfscp.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,11 @@ static int ScpStreamSend(WOLFSSH* ssh, byte* data, word32 sz)

/* Reads up to sz bytes into data, completing any rekey that fires mid-read.
*
* Flushes queued output before reading so a KEXINIT enqueued by a receive-side
* highwater rekey is actually sent, otherwise the peer can wait for our KEXINIT
* while we block on the read. On a read that fails with WS_REKEYING the worker
* is driven to finish the rekey and the read is retried. The helper is
* error-code transparent: every other status (WS_EOF, WS_EXTDATA,
* WS_CHANNEL_CLOSED, WS_SOCKET_ERROR_E, WS_WANT_READ/WS_WANT_WRITE, byte count)
* is returned unchanged so each caller keeps its existing branch handling.
* Flushes queued output first, or a KEXINIT from a receive-side highwater
* rekey sits unsent while both ends block on a read. A WS_REKEYING is driven
* to completion and a WS_EXTDATA is drained, then the read retries; every
* other status passes through unchanged, so callers keep their branch
* handling.
*/
static int ScpStreamRead(WOLFSSH* ssh, byte* data, word32 sz)
{
Expand Down
Loading