More fixes for channel_write()
This commit is contained in:
parent
3ea661a574
commit
ba2f21eb85
5
README
5
README
@ -1,6 +1,11 @@
|
|||||||
libssh2 - SSH2 library
|
libssh2 - SSH2 library
|
||||||
======================
|
======================
|
||||||
|
|
||||||
|
Version 0.10
|
||||||
|
------------
|
||||||
|
|
||||||
|
(Re)Fixed channel_write() to provide an opportunity for window space to become available again.
|
||||||
|
|
||||||
Version 0.9
|
Version 0.9
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
@ -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);
|
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)) {
|
if (!channel->blocking && (channel->local.window_size <= 0)) {
|
||||||
/* twiddle our thumbs until there's window space available */
|
/* Can't write anything */
|
||||||
if (libssh2_packet_read(session, 1) < 0) {
|
return 0;
|
||||||
/* Error occured, disconnect? */
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
packet_len = buflen + (stream_id ? 13 : 9); /* packet_type(1) + channelno(4) [ + streamid(4) ] + buflen(4) */
|
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;
|
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 */
|
/* Don't exceed the remote end's limits */
|
||||||
/* REMEMBER local means local as the SOURCE of the data */
|
/* REMEMBER local means local as the SOURCE of the data */
|
||||||
if (bufwrite > channel->local.window_size) {
|
if (bufwrite > channel->local.window_size) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user