mirror of https://github.com/wolfSSL/wolfssh.git
adjust stream_send behavior with WANT_WRITE
parent
61a41b5b7b
commit
73839469ed
|
@ -1410,6 +1410,7 @@ int wolfSSH_SendPacket(WOLFSSH* ssh)
|
|||
}
|
||||
|
||||
ssh->outputBuffer.idx = 0;
|
||||
ssh->outputBuffer.plainSz = 0;
|
||||
|
||||
WLOG(WS_LOG_DEBUG, "SB: Shrinking output buffer");
|
||||
ShrinkBuffer(&ssh->outputBuffer, 0);
|
||||
|
@ -7147,6 +7148,9 @@ int SendChannelData(WOLFSSH* ssh, word32 peerChannel,
|
|||
if (ret == WS_SUCCESS)
|
||||
ret = dataSz;
|
||||
|
||||
if (ssh->error == WS_WANT_WRITE)
|
||||
ssh->outputBuffer.plainSz = dataSz;
|
||||
|
||||
WLOG(WS_LOG_DEBUG, "Leaving SendChannelData(), ret = %d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -766,14 +766,13 @@ int wolfSSH_stream_send(WOLFSSH* ssh, byte* buf, word32 bufSz)
|
|||
if (ssh->error == WS_WANT_WRITE && ssh->outputBuffer.length != 0) {
|
||||
int ret;
|
||||
|
||||
bytesTxd = ssh->outputBuffer.length;
|
||||
WLOG(WS_LOG_DEBUG, "Trying to resend %d bytes\n", bytesTxd);
|
||||
bytesTxd = ssh->outputBuffer.plainSz;
|
||||
WLOG(WS_LOG_DEBUG, "\n\nTrying to resend %d bytes\n\n\n", bytesTxd);
|
||||
ssh->error = WS_SUCCESS;
|
||||
ret = wolfSSH_SendPacket(ssh);
|
||||
|
||||
/* return the amount sent on success otherwise return error found */
|
||||
return (ret == WS_SUCCESS)?
|
||||
bytesTxd - (int)ssh->outputBuffer.length : ret;
|
||||
return (ret == WS_SUCCESS)? bytesTxd : ret;
|
||||
}
|
||||
|
||||
bytesTxd = SendChannelData(ssh, ssh->channelList->peerChannel, buf, bufSz);
|
||||
|
|
|
@ -155,6 +155,7 @@ WOLFSSH_LOCAL const char* IdToName(byte);
|
|||
|
||||
typedef struct Buffer {
|
||||
void* heap; /* Heap for allocations */
|
||||
int plainSz; /* amount of plain text bytes to send with WANT_WRITE */
|
||||
word32 length; /* total buffer length used */
|
||||
word32 idx; /* idx to part of length already consumed */
|
||||
byte* buffer; /* place holder for actual buffer */
|
||||
|
|
Loading…
Reference in New Issue