1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-30 13:01:23 +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

@@ -512,6 +512,7 @@ int ssh_handle_packets(ssh_session session, int timeout) {
* (-1) means an infinite timeout.
* Specifying SSH_TIMEOUT_USER means to use the timeout
* specified in options. 0 means poll will return immediately.
* SSH_TIMEOUT_DEFAULT uses blocking parameters of the session.
* This parameter is passed to the poll() function.
*
* @param[in] fct Termination function to be used to determine if it is
@@ -530,6 +531,11 @@ int ssh_handle_packets_termination(ssh_session session, int timeout,
session->opts.timeout_usec);
else
timeout = SSH_TIMEOUT_NONBLOCKING;
} else if (timeout == SSH_TIMEOUT_DEFAULT){
if(ssh_is_blocking(session))
timeout = SSH_TIMEOUT_INFINITE;
else
timeout = SSH_TIMEOUT_NONBLOCKING;
}
ssh_timestamp_init(&ts);
tm = timeout;