diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2011-09-02 22:35:53 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2011-09-02 22:45:50 +0200 |
commit | 26be91fb8e074a2e507efdb482a330d68b2be90c (patch) | |
tree | aa63f2f3b582de126837a27f2d5929b599536b12 | |
parent | 43a3becf087465e737e1784171f90291ecbc8af0 (diff) | |
download | libssh-26be91fb8e074a2e507efdb482a330d68b2be90c.tar.gz libssh-26be91fb8e074a2e507efdb482a330d68b2be90c.tar.xz libssh-26be91fb8e074a2e507efdb482a330d68b2be90c.zip |
channels: Fix bug #52.
(cherry picked from commit a2c94abb92ead1503a0d6284609af41e53bef402)
Conflicts:
src/channels.c
-rw-r--r-- | src/channels.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/channels.c b/src/channels.c index 23376ac3..459f7c47 100644 --- a/src/channels.c +++ b/src/channels.c @@ -1133,6 +1133,8 @@ int channel_write_common(ssh_channel channel, const void *data, uint32_t origlen = len; size_t effectivelen; size_t maxpacketlen; + int timeout; + int rc; if(channel == NULL || data == NULL) { return -1; @@ -1150,7 +1152,10 @@ int channel_write_common(ssh_channel channel, const void *data, } enter_function(); - + if(ssh_is_blocking(session)) + timeout = -2; + else + timeout = 0; /* * Handle the max packet len from remote side, be nice * 10 bytes for the headers @@ -1174,7 +1179,7 @@ int channel_write_common(ssh_channel channel, const void *data, #ifdef WITH_SSH1 if (channel->version == 1) { - int rc = channel_write1(channel, data, len); + rc = channel_write1(channel, data, len); leave_function(); return rc; } @@ -1191,7 +1196,10 @@ int channel_write_common(ssh_channel channel, const void *data, /* nothing can be written */ ssh_log(session, SSH_LOG_PROTOCOL, "Wait for a growing window message..."); - goto out; + rc = ssh_handle_packets(session, timeout); + if (rc == SSH_ERROR || (channel->remote_window == 0 && timeout==0)) + goto out; + continue; } effectivelen = len > channel->remote_window ? channel->remote_window : len; } else { @@ -1230,7 +1238,10 @@ int channel_write_common(ssh_channel channel, const void *data, len -= effectivelen; data = ((uint8_t*)data + effectivelen); } - + /* it's a good idea to flush the socket now */ + do { + rc = ssh_handle_packets(session, timeout); + } while(ssh_socket_buffered_write_bytes(session->socket) > 0 && timeout != 0); out: leave_function(); return (int)(origlen - len); |