summaryrefslogtreecommitdiffstats
path: root/src/client.c
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2011-05-24 23:26:18 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-05-25 21:59:51 +0200
commit09b0018b938bfbbe0d5b5363b8e011aa7bfbf2f2 (patch)
treedf73e66ffd908551b2f020a0c4c5b23a35152153 /src/client.c
parent2624e603d4fc47d1bcf16cc1374628fe0b10f555 (diff)
downloadlibssh-09b0018b938bfbbe0d5b5363b8e011aa7bfbf2f2.tar.gz
libssh-09b0018b938bfbbe0d5b5363b8e011aa7bfbf2f2.tar.xz
libssh-09b0018b938bfbbe0d5b5363b8e011aa7bfbf2f2.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. (cherry picked from commit 59f7647cd97c62ab7a26725e5a166dcb54b27bc6)
Diffstat (limited to 'src/client.c')
-rw-r--r--src/client.c16
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);