mirror of
https://github.com/libssh2/libssh2.git
synced 2025-10-31 23:30:25 +03:00
window_size: redid window handling for flow control reasons
Until now, the window size (channel->remote.window_size) was being updated just after receiving the packet from the transport layer. That behaviour is wrong because the channel queue may grow uncontrolled when data arrives from the network faster that the upper layer consumes it. This patch adds a new counter, read_avail, which keeps a count of the bytes available from the packet queue for reading. Also, now the window size is adjusted when the data is actually read by an upper layer. That way, if the upper layer stops reading data, the window will eventually fill and the remote host will stop sending data. When the upper layers reads enough data, a window adjust packet is delivered and the transfer resumes. The read_avail counter is used to detect the situation when the remote server tries to send data surpassing the window size. In that case, the extra data is discarded. Signed-off-by: Salvador <sfandino@yahoo.com>
This commit is contained in:
committed by
Daniel Stenberg
parent
42aefdba79
commit
cdeef54967
@@ -356,6 +356,8 @@ struct _LIBSSH2_CHANNEL
|
||||
libssh2_channel_data local, remote;
|
||||
/* Amount of bytes to be refunded to receive window (but not yet sent) */
|
||||
uint32_t adjust_queue;
|
||||
/* Data immediately available for reading */
|
||||
uint32_t read_avail;
|
||||
|
||||
LIBSSH2_SESSION *session;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user