More fixes for channel_write()

This commit is contained in:
Sara Golemon 2005-05-06 18:30:43 +00:00
parent 3ea661a574
commit ba2f21eb85
2 changed files with 17 additions and 6 deletions

5
README
View File

@ -1,6 +1,11 @@
libssh2 - SSH2 library
======================
Version 0.10
------------
(Re)Fixed channel_write() to provide an opportunity for window space to become available again.
Version 0.9
-----------

View File

@ -861,12 +861,9 @@ 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 <= 0)) {
/* twiddle our thumbs until there's window space available */
if (libssh2_packet_read(session, 1) < 0) {
/* Error occured, disconnect? */
return -1;
}
if (!channel->blocking && (channel->local.window_size <= 0)) {
/* Can't write anything */
return 0;
}
packet_len = buflen + (stream_id ? 13 : 9); /* packet_type(1) + channelno(4) [ + streamid(4) ] + buflen(4) */
@ -886,6 +883,15 @@ LIBSSH2_API int libssh2_channel_write_ex(LIBSSH2_CHANNEL *channel, int stream_id
libssh2_htonu32(s, stream_id); s += 4;
}
/* twiddle our thumbs until there's window space available */
while (channel->local.window_size <= 0) {
/* Don't worry -- This is never hit unless it's a blocking channel anyway */
if (libssh2_packet_read(session, 1) < 0) {
/* Error occured, disconnect? */
return -1;
}
}
/* Don't exceed the remote end's limits */
/* REMEMBER local means local as the SOURCE of the data */
if (bufwrite > channel->local.window_size) {