From 671a9827394714cfc90d75c8a8fb2ccd86f80abf Mon Sep 17 00:00:00 2001 From: Oliver Stöneberg Date: Mon, 16 May 2011 06:49:38 -0700 Subject: connect: Set timeout on connect This also fixes error handling in ssh_poll_ctx_dopoll() and ssh_handle_packets(), so it won't loop forever on an actual timeout. --- src/client.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/client.c') diff --git a/src/client.c b/src/client.c index 66d4a9a..fccbb70 100644 --- a/src/client.c +++ b/src/client.c @@ -673,8 +673,6 @@ int ssh_connect(ssh_session session) { } else { ret=ssh_socket_connect(session->socket, session->host, session->port, session->bindaddr); - - /*, session->timeout * 1000 + session->timeout_usec); */ } if (ret == SSH_ERROR) { leave_function(); @@ -687,8 +685,12 @@ 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)) - ssh_handle_packets_termination(session,-1,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); + } 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); -- cgit