diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2013-02-11 21:37:05 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2013-07-13 14:03:42 +0200 |
commit | 66b37c856c29b77ab548063de2fb64a8435e8b9f (patch) | |
tree | 56ef36772657682ab74df2d188584f1da74ca6ae /src/channels.c | |
parent | 6bc64c368d49d2c775fa4a0e94dc65fcee746710 (diff) | |
download | libssh-66b37c856c29b77ab548063de2fb64a8435e8b9f.tar.gz libssh-66b37c856c29b77ab548063de2fb64a8435e8b9f.tar.xz libssh-66b37c856c29b77ab548063de2fb64a8435e8b9f.zip |
session: Introduce SSH_TIMEOUT_DEFAULT
The default timeout of 30seconds is very nice when connecting to a new SSH
session, however it completely breaks the synchronous blocking API.
Use SSH_TIMEOUT_DEFAULT when in blocking mode so channel reads&write are blocking
as expected
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/channels.c')
-rw-r--r-- | src/channels.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/channels.c b/src/channels.c index 6e9b2eb0..47fcee09 100644 --- a/src/channels.c +++ b/src/channels.c @@ -1222,7 +1222,7 @@ static int ssh_waitsession_unblocked(void *s){ * SSH_AGAIN Timeout elapsed (or in nonblocking mode) */ int ssh_channel_flush(ssh_channel channel){ - return ssh_blocking_flush(channel->session, SSH_TIMEOUT_USER); + return ssh_blocking_flush(channel->session, SSH_TIMEOUT_DEFAULT); } int channel_write_common(ssh_channel channel, const void *data, @@ -1282,7 +1282,7 @@ int channel_write_common(ssh_channel channel, const void *data, } #endif if (ssh_waitsession_unblocked(session) == 0){ - rc = ssh_handle_packets_termination(session, SSH_TIMEOUT_USER, + rc = ssh_handle_packets_termination(session, SSH_TIMEOUT_DEFAULT, ssh_waitsession_unblocked, session); if (rc == SSH_ERROR || !ssh_waitsession_unblocked(session)) goto out; @@ -1298,7 +1298,7 @@ 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..."); - rc = ssh_handle_packets_termination(session, SSH_TIMEOUT_USER, + rc = ssh_handle_packets_termination(session, SSH_TIMEOUT_DEFAULT, ssh_channel_waitwindow_termination,channel); if (rc == SSH_ERROR || !ssh_channel_waitwindow_termination(channel)) goto out; @@ -2681,13 +2681,13 @@ int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count, int is_std } } - /* block reading until all bytes are read + /* block reading until at least one byte has been read * and ignore the trivial case count=0 */ ctx.channel = channel; ctx.buffer = stdbuf; - ctx.count = count; - rc = ssh_handle_packets_termination(session, SSH_TIMEOUT_USER, + ctx.count = 1; + rc = ssh_handle_packets_termination(session, SSH_TIMEOUT_DEFAULT, ssh_channel_read_termination, &ctx); if (rc == SSH_ERROR){ leave_function(); |