mirror of https://github.com/wolfSSL/wolfssh.git
Send channel window adjust update when the receive buffer
has processed at least half of its available space. By default, the receive window is 1MB, and the window size is increased every 512kB.pull/21/head
parent
919ed1f944
commit
b3ee5cd381
|
|
@ -3676,11 +3676,6 @@ int SendChannelWindowAdjust(WOLFSSH* ssh, uint32_t peerChannel,
|
|||
WLOG(WS_LOG_DEBUG, "Invalid peer channel");
|
||||
ret = WS_INVALID_CHANID;
|
||||
}
|
||||
#if 0
|
||||
/* Check bytesToAdd against the buffer size */
|
||||
if (bytesToAdd > ssh->inputBuffer.bufferSz - ssh->inputBuffer.length)
|
||||
ret = WS_BAD_ARGUMENT;
|
||||
#endif
|
||||
if (ret == WS_SUCCESS)
|
||||
ret = PreparePacket(ssh, MSG_ID_SZ + (UINT32_SZ * 2));
|
||||
|
||||
|
|
@ -3699,14 +3694,9 @@ int SendChannelWindowAdjust(WOLFSSH* ssh, uint32_t peerChannel,
|
|||
ret = BundlePacket(ssh);
|
||||
}
|
||||
|
||||
if (ret == WS_SUCCESS) {
|
||||
if (ret == WS_SUCCESS)
|
||||
ret = SendBuffered(ssh);
|
||||
|
||||
WLOG(WS_LOG_INFO, " bytesToAdd = %u", bytesToAdd);
|
||||
WLOG(WS_LOG_INFO, " windowSz = %u", channel->windowSz);
|
||||
channel->windowSz += bytesToAdd;
|
||||
WLOG(WS_LOG_INFO, " update windowSz = %u", channel->windowSz);
|
||||
}
|
||||
WLOG(WS_LOG_DEBUG, "Leaving SendChannelWindowAdjust(), ret = %d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
27
src/ssh.c
27
src/ssh.c
|
|
@ -408,6 +408,33 @@ int wolfSSH_stream_read(WOLFSSH* ssh, uint8_t* buf, uint32_t bufSz)
|
|||
WMEMCPY(buf, inputBuffer->buffer + inputBuffer->idx, bufSz);
|
||||
inputBuffer->idx += bufSz;
|
||||
|
||||
if (inputBuffer->length > inputBuffer->bufferSz / 2) {
|
||||
uint32_t usedSz = inputBuffer->length - inputBuffer->idx;
|
||||
uint32_t bytesToAdd = inputBuffer->idx;
|
||||
int sendResult;
|
||||
|
||||
WLOG(WS_LOG_DEBUG, "Making more room: %u", usedSz);
|
||||
if (usedSz) {
|
||||
WLOG(WS_LOG_DEBUG, " ...moving data down");
|
||||
WMEMMOVE(inputBuffer->buffer,
|
||||
inputBuffer->buffer + bytesToAdd, usedSz);
|
||||
}
|
||||
|
||||
sendResult = SendChannelWindowAdjust(ssh,
|
||||
ssh->channelList->peerChannel,
|
||||
bytesToAdd);
|
||||
if (sendResult != WS_SUCCESS)
|
||||
bufSz = sendResult;
|
||||
|
||||
WLOG(WS_LOG_INFO, " bytesToAdd = %u", bytesToAdd);
|
||||
WLOG(WS_LOG_INFO, " windowSz = %u", ssh->channelList->windowSz);
|
||||
ssh->channelList->windowSz += bytesToAdd;
|
||||
WLOG(WS_LOG_INFO, " update windowSz = %u", ssh->channelList->windowSz);
|
||||
|
||||
inputBuffer->length = usedSz;
|
||||
inputBuffer->idx = 0;
|
||||
}
|
||||
|
||||
WLOG(WS_LOG_DEBUG, "Leaving wolfSSH_stream_read(), rxd = %u", bufSz);
|
||||
return bufSz;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue