This patch seems to improve matters, for the slow.c just posted.
I'm not sure I understand all the implications of moving the adjust
after the read, but I don't see how to know the right adjustment to
apply without reading first: I very frequently get short reads from
this function.
Nathan Myers
ncm_at_cantrip.org
diff --git a/src/channel.c b/src/channel.c
index 4f41e1f..4746dc5 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -1888,7 +1888,7 @@ LIBSSH2_API ssize_t
libssh2_channel_read_ex(LIBSSH2_CHANNEL *channel, int stream_id, char
*buf,
size_t buflen)
{
- int rc;
+ int rc, rc2;
unsigned long recv_window;
if(!channel)
@@ -1896,14 +1896,14 @@ libssh2_channel_read_ex(LIBSSH2_CHANNEL
*channel, int stream_id, char *buf,
recv_window = libssh2_channel_window_read_ex(channel, NULL, NULL);
- if(buflen > recv_window) {
- BLOCK_ADJUST(rc, channel->session,
- _libssh2_channel_receive_window_adjust(channel,
buflen,
- 1, NULL));
- }
-
BLOCK_ADJUST(rc, channel->session,
_libssh2_channel_read(channel, stream_id, buf, buflen));
+
+ if (rc > 0) {
+ BLOCK_ADJUST(rc2, channel->session,
+ _libssh2_channel_receive_window_adjust(channel, rc,
+ (buflen > recv_window), NULL));
+ }
return rc;
}
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2013-01-17