Handle Client-To-Server channel windowing.

This commit is contained in:
Sara Golemon
2005-01-20 21:33:30 +00:00
parent bfc2f5039e
commit 5f7470700e
2 changed files with 15 additions and 2 deletions

View File

@@ -902,7 +902,7 @@ LIBSSH2_API int libssh2_channel_write_ex(LIBSSH2_CHANNEL *channel, int stream_id
libssh2_error(session, LIBSSH2_ERROR_CHANNEL_EOF_SENT, "EOF has already been sight, data might be ignored", 0);
}
if (channel->blocking && channel->local.window_size_initial && (channel->local.window_size <= 0)) {
if (channel->blocking && (channel->local.window_size <= 0)) {
/* twiddle our thumbs until there's window space available */
if (libssh2_packet_read(session, 1) < 0) {
/* Error occured, disconnect? */
@@ -925,7 +925,7 @@ LIBSSH2_API int libssh2_channel_write_ex(LIBSSH2_CHANNEL *channel, int stream_id
/* Don't exceed the remote end's limits */
/* REMEMBER local means local as the SOURCE of the data */
if (channel->local.window_size_initial && (buflen > channel->local.window_size)) {
if (buflen > channel->local.window_size) {
buflen = channel->local.window_size;
}
if (buflen > channel->local.packet_size) {

View File

@@ -475,6 +475,19 @@ static int libssh2_packet_add(LIBSSH2_SESSION *session, unsigned char *data, siz
return retval;
}
break;
case SSH_MSG_CHANNEL_WINDOW_ADJUST:
{
LIBSSH2_CHANNEL *channel = libssh2_channel_locate(session, libssh2_ntohu32(data + 1));
unsigned long bytestoadd = libssh2_ntohu32(data + 5);
if (channel && bytestoadd) {
channel->local.window_size += bytestoadd;
}
LIBSSH2_FREE(session, data);
return 0;
}
break;
}
packet = LIBSSH2_ALLOC(session, sizeof(LIBSSH2_PACKET));