diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2011-05-24 23:26:18 +0200 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2011-05-24 23:26:18 +0200 |
commit | 59f7647cd97c62ab7a26725e5a166dcb54b27bc6 (patch) | |
tree | 34dad1189e803af0b8d1d3caa83cd220a950bc3f /src/client.c | |
parent | 4d6b1aa2c7ea67d6909680254b7ae68aa437a6ef (diff) | |
download | libssh-59f7647cd97c62ab7a26725e5a166dcb54b27bc6.tar.gz libssh-59f7647cd97c62ab7a26725e5a166dcb54b27bc6.tar.xz libssh-59f7647cd97c62ab7a26725e5a166dcb54b27bc6.zip |
Introduced ssh_timeout_elapsed functions
Functions to mesure elapsed time before and after a serie of
calls. Introduces a dependancy to clock_gettime() and librt,
hope this doesn't break anything. Porting to gettimeofday() should
not be too hard.
Diffstat (limited to 'src/client.c')
-rw-r--r-- | src/client.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/client.c b/src/client.c index fccbb701..84a0ad92 100644 --- a/src/client.c +++ b/src/client.c @@ -685,12 +685,16 @@ int ssh_connect(ssh_session session) { ssh_log(session,SSH_LOG_PROTOCOL,"Socket connecting, now waiting for the callbacks to work"); pending: session->pending_call_state=SSH_PENDING_CALL_CONNECT; - if(ssh_is_blocking(session)) { - int timeout = session->timeout * 1000 + session->timeout_usec; - if (timeout <= 0) - timeout = -1; - ssh_handle_packets_termination(session,timeout,ssh_connect_termination,session); - } + if(ssh_is_blocking(session)) { + int timeout = session->timeout * 1000 + session->timeout_usec; + if (timeout <= 0) + timeout = -1; + ssh_handle_packets_termination(session,timeout,ssh_connect_termination,session); + if(!ssh_connect_termination(session)){ + ssh_set_error(session,SSH_FATAL,"Timeout connecting to %s",session->host); + session->session_state = SSH_SESSION_STATE_ERROR; + } + } else ssh_handle_packets_termination(session,0,ssh_connect_termination, session); ssh_log(session,SSH_LOG_PACKET,"ssh_connect: Actual state : %d",session->session_state); |