1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-08-08 19:02:06 +03:00

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>
This commit is contained in:
Aris Adamantiadis
2013-02-11 21:37:05 +01:00
committed by Andreas Schneider
parent 6bc64c368d
commit 66b37c856c
3 changed files with 17 additions and 6 deletions

View File

@@ -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();